select count(id) as 'count' FROM `doctor` where 1 and ( region in (37) OR region2 in (37) OR region3 in (37) OR region4 in (37) OR region5 in (37) ) and ( building_id IN(, ) or building_id2 IN(,) or building_id3 IN(,) or building_id4 IN(,) or building_id5 IN(,) ) ORDER BY `grade_service`, `doctor_id`