SELECT `u`.*FROM `app_aobject` `o`JOIN `sif_cities` `c` ON `c`.`cityId` = `o`.`cityId`JOIN `app_aunit` `u` ON `u`.`objectId` = `o`.`aObjectId`WHERE `c`.`cityId` = '2' AND NOT EXISTS (SELECT 1 FROM app_booking ab WHERE u.aUnitId = ab.aUnitId and ((fromDate >= '' and fromDate <= '') or (toDate >= '' and toDate <= '')))
SELECT * FROM sif_regions where regionId in (select regionId from app_aobject a inner join sif_cities c on a.cityId = c.cityId);
SELECT * FROM sif_cities where cityId in (select cityId from app_aobject);
SELECT * FROM sif_islands where islandId in (select islandId from app_aobject);
SELECT *FROM `app_unit_types`WHERE `active` = 1