Query: | SELECT SQL_CALC_FOUND_ROWS IF (FIND_IN_SET('18', `T1`.`Crossed`) > 0, 1, 0) AS `Crossed_listing`, `T1`.*, `T3`.`Key` AS `Key`, `T3`.`Type` AS `Listing_type`, `T3`.`Parent_keys`, `T3`.`Parent_IDs`, `T3`.`Path` AS `Path`, IF( `T1`.`Sub_status`='invisible' OR `T1`.`Sub_status` = 'visible', `T1`.`Main_photo`, IF(`T1`.`Main_photo`='',`T1`.`Main_photo`,CONCAT( SUBSTRING_INDEX(`T1`.`Main_photo`, '.', 1), '_', `T1`.`Sub_status` ,'_bs', '.', SUBSTRING_INDEX(`T1`.`Main_photo`, '.', -1)))) AS `Main_photo` ,IF(`T1`.`Date` != `T1`.`HighlightDate` AND `T1`.`HighlightDate` != '0000-00-00 00:00:00', '1', '0') as 'is_highlighted', IF(`T1`.`Featured_date`, '1', '0') `Featured` FROM `fl_listings` AS `T1` LEFT JOIN `fl_categories` AS `T3` ON `T1`.`Category_ID` = `T3`.`ID` LEFT JOIN `fl_data_formats` AS `TDF_units` ON `TDF_units`.`Key` = SUBSTRING_INDEX(`T1`.`square_feet`, '|', -1) LEFT JOIN `fl_data_formats` AS `TDF_units` ON `TDF_units`.`Key` = SUBSTRING_INDEX(`T1`.`lot_size`, '|', -1) WHERE `T1`.`Status` = 'active' AND (`T1`.`Category_ID` = '18' OR (FIND_IN_SET('18', `T1`.`Crossed`) > 0) OR FIND_IN_SET('18', `T3`.`Parent_IDs`) > 0 ) AND `T1`.`Sub_status` <> 'invisible' AND `T1`.`newbuilding_2` = '' AND `T1`.`bathrooms` = '2-3' AND `T1`.`bedrooms` = '3-4' AND ((`T1`.`Category_ID` = 18 OR FIND_IN_SET(18, `T3`.`Parent_IDs`) > 0) OR (FIND_IN_SET(18, `T1`.`Crossed`) > 0)) ORDER BY `Featured` DESC , SUBSTRING_INDEX(`T1`.`lot_size`, '|', 1)/IF(`TDF_units`.`Rate` IS NULL, 1, `TDF_units`.`Rate`) ASC LIMIT 0, 12 |