I have a database with three tables in my database namely catering, room, room_booking and I am currently access room and room_booking in the following way – if two conditions are met:
SELECT name,capacity,licensed,$price FROM room
WHERE capacity BETWEEN '$minCapacity' AND '$maxCapacity'
AND room_id NOT IN
(SELECT room_id
FROM room_booking
WHERE date_booked = '$date')
The table catering has three columns room_id,grade,cost.
I need to select all the fields on table with a matching grade as so:
SELECT * FROM catering where grade=$grade;
How do I add this condition to my main SQL query with the other two conditions intact so that there three conditions in total working together?
Add a
JOINagainstcatering. Substitute the correct column name forroom.room_idif that isn’t correct (such as if it is supposed to beroom.id).Not sure why you have used
$pricein the select list. Perhaps that was a typo, or you were substituting a PHP variable?