I'm trying to get the results(entire rows) of a property table using the result of a JOIN of 2 tables. A "booking_tbl" and "property_tbl". The first condition is that the property not be already booked within a specified date period (startDate, endDate). The second condition is that a number (property_tbl.max_guest) must be equal to or larger than another specified number (variable: num_guest) to accommodate all guests.
So far what I've managed to achieve is:
SELECT * FROM property_tbl
INNER JOIN booking_tbl ON booking_tbl.propertyId = property_tbl.id
WHERE NOT booking_tbl.endDate > '17-10-24' AND booking_tbl.startDate < '17-10-31';
The above returns all of the available properties which occur in the booking_tbl only, The listings from property_tbl which have not previously been booked are omitted.
After some research on this I think I should be using a LEFT JOIN? What is the difference between "INNER JOIN" and "OUTER JOIN"?
But unfortunately I'm having difficulty formatting the query and understanding how to add another JOIN and filter the number range.
Some help with this query would be greatly appreciated.
Thank you in advance