sql - MYSQL : Find records between particular period -
i have 1 table named "checkinguestusers" in there columns 'checkintime(datetime), checkouttime(datetime),rooms(varchar)
there particular user booked rooms within particular time as,
userid checkintime checkouttime rooms 25 2014-12-04 00:00:00 2014-12-05 23:59:59 101,102
now user or same user wants book room within
"2014-12-03 00:00:00" "2014-12-04 23:59:59" or "2014-12-04 00:00:00" "2014-12-04 23:59:59"
then system should return room list except 101,102 these rooms booked "2014-12-04 00:00:00" "2014-12-04 23:59:59"
i want sql query if select time 1 of above both returns rooms booked within period.
i have tried using between , greater or less conditions in sql failed exact result.
select room_id rooms checkintime null or checkouttime <= bookfrom , checkintime null or bookto <= checkintime
is homework?
Comments
Post a Comment