Select - Time comparison does not work

Asked

Viewed 32 times

0

I am trying to make a query to eliminate results in which the end time of the event is equal to 00:00:00, I made the query this way:

select nome, local, hora_inicio, hora_fim, data_inicio, data_fim 
from agenda
where hora_fim <> 00:00:00;

PS: I also tried putting != in place of <>, but it also didn’t work, keeps returning events with end time equal to 00:00:00.

PS: The start-time and end-time fields are as team in the database.

1 answer

1


Use the function TEAM():

select nome, local, hora_inicio, hora_fim, data_inicio, data_fim 
from agenda
where TIME(`hora_fim`) <> '00:00:00';
  • I tried to do this, however, as the query is inside a PHP variable, it is conflicting with the quotes, I believe that’s why it’s not working, I tried both ways, but it doesn’t work: $query->Where(' TIME("a.hora_end") <> "00:00:00:00") '); $query->Where(' TIME('a.hora_end') <> '00:00:00') ');

  • Quotes must escape! In Java the escape character is "".

Browser other questions tagged

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