I am doing project of hotel booking system in php and mysql
I created the rooms table which is below
room_no| roo_id | room_type
D1 | 1 | Deluxe
R1 | 2 | AC
R2 | 3 | Non Ac
C1 | 4 | Cottage
this table is about rooms represent total rooms in hotel.
this is customer_booking table,
customer_id | Cust_name | email | Address | room_type | room_no| cost|check_in | check_out
1 | satyawan |ss@gmail.com| xy | AC | R1 |5000 | 2012-12-26|2012-12-30
2 |satyawan | lahu@gmail.com|unr | Non A/C | R6 | 20002012-01-01|2012-12-07
3 |satyawan | lahu@gmail.com|unr | Non A/C | R8 | 2013-01-01 |2013-01-10
4 |satyawan | lahu@gmail.com|unr | Non A/C | R9 | 2013-01-10 |2013-01-16
5 |satyawan | lahu@gmail.com|unr | Non A/C | R6 | 2013-01-01 |2013-01-20
i have fired query on join of this both table for sort data of unbooked rooms. the query is below
SELECT *
FROM rooms
LEFT JOIN customer_booking
ON customer_booking.room_no = rooms.room_no
WHERE customer_booking.client_id IS NULL
OR (customer_booking.check_out >= 2013-01-01
AND customer_booking.check_in >= 2013-01-10)
OR (customer_booking.check_out <= 2013-01-01
AND customer_booking.check_out <= 2013-01-10)
but i want only data of unbooked rooms only.
if rooms is already book then it have to show that this room is already book on this date.
i cant get any idea about it.
Try to use this query. If the last field
room_customer_idis 0 then room is free otherwise it shows customer_id who reserved this room.