Catch the next event with Mysql

Asked

Viewed 15 times

0

I have a system from which take the current day schedule and the next schedule, see:

inserir a descrição da imagem aqui

To get the current day’s schedule, I did it this way:

// DataAgenda = NOW()
mysqli_query($this-conexao,"SELECT * FROM agenda WHERE DATE(DataAgenda) = CURDATE()");

And the next event, how can I catch it?

1 answer

0

I was able to solve it this way:

mysqli_query($this-conexao,"SELECT * FROM agenda WHERE DATE(DataAgenda) > CURDATE() ORDER BY DataAgenda LIMIT 1");
  • 1

    If the record of the next event is before the current will go bad :D... In fact, if there is a record before it is at a later date than the next, it will return.

  • 3

    Don’t forget to add one order by DataAgenda. What Voce does is take the first record with the DATE(DataAgenda) > CURDATE(). That’s not going to be the next event.

  • Well noted William. Thank you.

  • Sorry dvd, I couldn’t understand.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.