I have a query which uses BETWEEN
for showing the records between two dates. My query needs to show records whose arrival_date
and departure_date
between specific dates. But query somehow shows all records.
Column types are DATE
.
SELECT DISTINCT art.* FROM accommodation_room_types art
INNER JOIN accommodation_rooms ar ON art.id = ar.room_type
INNER JOIN accommodation a ON art.accommodation = a.id
WHERE a.id = 13 AND NOT EXISTS
(
SELECT 1 FROM booked_rooms br INNER JOIN booking b ON br.booking = b.id
WHERE br.room = ar.id
AND
(
b.arrival_date BETWEEN '2017-12-16' AND '2018-04-16'
)
OR
(
b.departure_date BETWEEN '2017-12-16' AND '2018-04-16'
)
)
Even I write BETWEEN 'asd' AND 'asd'
, it still shows all records and doesn't give any format error.
Is my query wrong for showing records between two specific dates?