SELECT v.*, `metros`.`name` AS metro, IF(`user2vuz`.`u_id`>1000, `user2vuz`.`u_id`, NULL) AS u_id, IFNULL(o.ops, 0) AS ops, IFNULL(s.specs, 0) AS specs, IF(v.`packet`="sert" OR v.`partner`="1", RAND(), 0) AS randseed FROM ( SELECT `vuzes`.`id`, `vuzes`.`name`, `vuzes`.`subj_id`, `vuzes`.`city_id`, `vuzes`.`gos`, `vuzes`.`hostel`, `vuzes`.`military`, `vuzes`.`vedom`, `vuzes`.`metro_id`, `vuzes`.`rating`, `vuzes`.`noAbitur`, `vuzes`.`ege`, `vuzes`.`short_seo`, IF(`vuzes`.`packetEnd`>DATE(NOW()), "sert", "") AS packet, `vuzes`.`partner` FROM `vuzes` WHERE `delReason`="" AND `vuzes`.`parent_id` IS NULL AND `vuzes`.`delReason`="" ) v LEFT JOIN `user2vuz` ON `user2vuz`.`vuz_id`=v.`id` LEFT JOIN `general`.`metros` ON `metros`.`id`=v.`metro_id` LEFT JOIN ( SELECT `vuz_id`, count(*) AS specs FROM `vuz`.`specs` GROUP BY `vuz_id` ) s ON s.`vuz_id` = v.`id` LEFT JOIN ( SELECT `vuz_id`, count(*) AS ops FROM `vuz`.`opinions` WHERE `approved`="1" GROUP BY `vuz_id` ) o ON o.`vuz_id` = v.`id` WHERE `specs`.`form`="4" GROUP BY v.`id` ORDER BY v.`packet` DESC, v.`partner` DESC, randseed, v.`rating` DESC LIMIT 0, 30
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'specs.form' in 'where clause'