How to select records in a table using the present datetime as a reference?

0

This select returns me the oldest records to future ones. But I wanted to exclude from the results the events that have already passed and display the current event first.

SELECT id, programa, descricao,data_hora 
   from wp_programacao
   where id >= (SELECT programa
                 from  wp_programacao
                 where data_hora <= now()
                 order by data_hora desc
                 limit 1)
  order by data_hora asc
  limit 5;
    
asked by anonymous 04.05.2017 / 07:27

1 answer

1
select id, programa, descricao, data_hora 
from wp_programacao
where data_hora >= now() 
order by data_hora asc
limit 5;
    
04.05.2017 / 13:40