SELECT SQL_CALC_FOUND_ROWS soc.id, soc.id, soc.name AS name, soc.latitude, soc.longitude, soc.id_state_category,soc.update_time,soc.new_state,soc.has_image
FROM smtbl_societes soc
JOIN smtbl_societes_categories sc ON (soc.id=sc.id_society AND sc.id_category=6)
WHERE
(soc.id_address_city=204822 OR soc.id_address_city IN (SELECT id FROM smtbl_address_cities WHERE id_district_parent=204822)) AND soc.deleted!=1
AND soc.id IN (SELECT id_society FROM smtbl_societes_categories WHERE id_category=11)
ORDER BY soc.has_image DESC,update_time DESC
LIMIT 0, 15