This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select `sites`.*, (select count(*) from `views` where `sites`.`id` = `views`.`site_id`) as `views_count`, (select count(*) from `orders` where `sites`.`id` = `orders`.`site_id` and `orders`.`deleted_at` is null) as `orders_count`, (select count(*) from `clients` inner join `favorites` on `clients`.`id` = `favorites`.`client_id` where `sites`.`id` = `favorites`.`site_id`) as `favorites_count`, (select count(*) from `clients` inner join `interests` on `clients`.`id` = `interests`.`client_id` where `sites`.`id` = `interests`.`site_id`) as `interests_count` from `sites` where `status` = 'APPROVED' and `url` like '%1001%' and ((exists (select * from `offers` where `sites`.`id` = `offers`.`site_id` and exists (select * from `types` inner join `offer_type` on `types`.`id` = `offer_type`.`type_id` where `offers`.`id` = `offer_type`.`offer_id` and `offer_type`.`sale_coin` = 'BRL' and `offer_type`.`sale` >= 0 and `offer_type`.`sale` <= 570739429.26 and `type_id` = '9' and `types`.`deleted_at` is null))) or (exists (sel |