
I have above mysql table with available dates and prices. Second table includes room details. How can I join two tables to get available rooms between two dates and not get duplicate content.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is hard to come up with a complete answer for you here, as you are only showing us the table which contains the bookings – we cannot know what range of rooms are available.
SQL which returns the room_id’s for rooms which are booked for at least part of the selected period could be:
If you had a table of rooms (rather than bookings), it would be possible for you to return a list of any rooms not booked during that period with:
AMENDMENT
Based on the feedback by OP, the assumptions are now:
dtand ending the following day (ie hotel rooms)As such, the amended code is: