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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -