I have a tables rooms, apartments and hotel. Now its easy for me to get all free rooms, name of hotel address or same thing for apartments by using separate queries ex :
Get all free rooms :
SELECT hotel.name, count(*) AS num_of_free_rooms
FROM hotel, rooms
WHERE rooms.occupied !=0
AND hotel.hotel_id = rooms.room_hotel
GROUP BY hotel.hotel_id
Get all free apartments :
SELECT hotel.name, count(*) AS num_of_free_ap
FROM hotel, apartments
WHERE apartments.occupied_ap !=0
AND hotel.hotel_id = apartments.apartment_hotel
GROUP BY hotel.hotel_id
How could I get results like this :
Name of a hotel | Number of free rooms other than 0 | Number of apartments 0 or any other
Should I organize my data differently, like adding in the table rooms field type 1 for rooms, 2 for apartments or do it with separate tables. I'm open to any suggestions in order to get results that I need.