mysql - datetime select with -15 minute interval showing wrong result -


for room reservation page i'm making query entries among 3 tables. datetime values in 1 table, table keeps info if room key has been checked out. , table keeps reservation information. if current time has past start of reservation time @ least 15 minutes , key has not been checked out, entry should deleted. problem is, deletes future reservations, start time of reservation has not past yet. query looks this.

select dt.field_reservation_datetime_value      , dt.entity_id      , co.field_reservation_checked_out_value      , co.entity_id      , res.reservation_id    field_data_field_reservation_datetime dt    join field_data_field_reservation_checked_out co      on co.entity_id = dt.entity_id    join studyroom_reservation res      on res.reservation_id = co.entity_id   co.field_reservation_checked_out_value = 0     , date (dt.field_reservation_datetime_value) <= now() - interval 15 minute 

right 9:52am, shouldn't showing next 2 hours , 38 minutes. this:

enter image description here

any idea may doing wrong?

edit: table alias added , screenshot

solved following code

select dt.*, co.*, res.* field_data_field_reservation_datetime dt  join field_data_field_reservation_checked_out co  on co.entity_id = dt.entity_id join studyroom_reservation res  on res.reservation_id = co.entity_id  co.field_reservation_checked_out_value = 0  , ((dt.field_reservation_datetime_value)  <= date_format(now() - interval 15 minute,'%y-%m-%d %h:%i:%s')) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -