select `products`.*, `category_product`.`product_category_id` as `pivot_product_category_id`, `category_product`.`product_id` as `pivot_product_id` from `products` innerjoin `category_product` on `products`.`id` = `category_product`.`product_id` where `category_product`.`product_category_id` =6and `products`.`deleted_at` isnull
select `unions`.*, (selectcount(*) from `markets` where `unions`.`id` = `markets`.`union_id` and `province_id` =89and `province_id` =89and `markets`.`deleted_at` isnull) as `markets_count` from `unions`