从 table 查询 Select

Query Select from table

我正在做一个关于酒店客房预订的项目。

我有 4 张桌子:

Rooms ( room_id, category, price);

booking_rooms (idbr, room_id, booking_id);

bookings (booking_id,client_id, checkin, checkout);

clients(client_id, fistname,lastname, address,phone,email);

我想创建一个搜索表单来检查入住和退房日期之间的可用房间和类别。

SELECT * FROM rooms 
 WHERE room_id NOT IN (select room_id 
                         from bookings_rooms 
                        WHERE (checkin < '$checkindate' 
                               AND checkout > '$checkoutdate') 
                           or (checkin> '$checkindate' 
                               AND checkin< '$checkindate'))

这就是我所做的。而且它不起作用。

你们能帮我解决这个问题吗?你能给我一个主意吗?

select * from rooms 
where room_id not in 
         (select room_id from bookings_rooms
                         where booking_id where not in //or in :)
                                        (select booking_id from bookings
                                                 where (checkin < '$checkindate' 
                                                AND checkout > '$checkoutdate') 
                                                or (checkin> '$checkindate' 
                                                AND checkin< '$checkindate')))