this question has answer here:
- sql statement ignoring parameter 1 answer
i have query uses between
showing records between 2 dates. query needs show records arrival_date
, departure_date
between specific dates. query somehow shows records.
column types date
.
select distinct art.* accommodation_room_types art inner join accommodation_rooms ar on art.id = ar.room_type inner join accommodation on art.accommodation = a.id a.id = 13 , not exists ( select 1 booked_rooms br inner join booking b on br.booking = b.id br.room = ar.id , ( b.arrival_date between '2017-12-16' , '2018-04-16' ) or ( b.departure_date between '2017-12-16' , '2018-04-16' ) )
even write between 'asd' , 'asd'
, still shows records , doesn't give format error. query wrong showing records between 2 specific dates?
i don't know if logic right or wrong, syntax not doing intend. suggest:
where a.id = 13 , not exists (select 1 booked_rooms br inner join booking b on br.booking = b.id br.room = ar.id , (b.arrival_date between '2017-12-16' , '2018-04-16' or b.departure_date between '2017-12-16' , '2018-04-16' ) )
it strikes me empty space in query makes hard see logic written as: a , b or c
. intention (presumably) a , (b or c)
.
Comments
Post a Comment