php - logics extracting right dates from mysql -


a little problem dates management in mysql. have table of event dates called event_dates:

id, date (type date), fk_event 

and table called event (id, event_name, event_body, status)

i check if now() minor smallest date, greater greatest date , if smallest

the first 2 cases ok, how can tell mysql third option? means "if now()>smallest && now()<greatest select next date bigger today". how i?

sure easy accomplish, honestly, cannot figure out after 3 hours of searching , trying. all.

could you?

or maybe misunderstood problem??

select if(  now() < (select min(date) event_dates)  , now() > (select max(date) event_dates), (select date event_dates date > now() order date asc limit 1),  '-1' ); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -