SELECT DISTINCT g.id, g.cod, g.group_id, g.name, g.url_name, g.short_description, g.price, g.price_purchase, g.price_old, g.availability, IF((SELECT MAX(p.availability) FROM pricelist_loaded p WHERE p.good=g.id)>0, 1, -1) as `exists`,IF((SELECT COUNT(p3.id) FROM pricelist_loaded p3 WHERE p3.good=g.id)>0, 1, 0) as relation, IF(g.price > 0, 0, 1) as noprice FROM goods_cats gc LEFT JOIN goods g ON (g.id = gc.good) WHERE g.public = 1 AND (0 < (SELECT `__b`.`public` FROM `brands` as `__b` WHERE `__b`.`id`=`g`.`brand_id` LIMIT 1)) AND gc.cat=685 GROUP BY g.id ORDER BY noprice ASC, `exists` DESC, g.price ASC LIMIT 0 ,12
1030: Got error 28 from storage engine