SELECT DISTINCT prods.id, prods.aver, prods.title_0, prods.title_0, prods.is_promo, prods.is_action, prods.is_razpr, prods.is_new, prods.catnom,
(SELECT orderby FROM cats WHERE id=(SELECT cat_id FROM prod_cat WHERE prod_id=prods.`id` ORDER BY cat_id DESC LIMIT 1)) order_cat,
(select count(prod_cat.id) from prod_cat where prod_id=prods.id and cat_id=109) is_kant,
(select min(price) from prod_items where prod_id=prods.id) price,
(select min(promo) from prod_items where prod_id=prods.id and promo is not null and promo > 0) promo,
(select count(id) from prod_items where prod_id=prods.id and istatus in (2, 3, 4, 5)) promo_cnt,
(SELECT name_0 FROM vals WHERE id=producer_id ) producername, producer_id
FROM prods
LEFT JOIN prod_cat ON prod_cat.prod_id=prods.id
LEFT JOIN prod_vals ON prod_vals.prod_id=prods.id
LEFT JOIN vals ON vals.id=prod_vals.val_id where prods.is_hidden=0 and not exists(select id from prod_cat where prod_id=prods.id and exists(select id from cats where id=prod_cat.cat_id and is_hidden=1)) and prod_cat.cat_id=245 ORDER BY order_cat, prod_cat.cat_id, prods.orderby, prods.aver, id DESC limit 0, 60