SELECT p.title_1 AS title, p.url_1 AS url, p.price, p.discount_price, p.id, p.product_outlet, "" AS caturl, p.discount_begins, p.brand, p.discount_ends, p.rating, p.rates, (SELECT filename FROM products_files WHERE active = 1 AND type="pictures" AND parent_id = p.id ORDER BY priority ASC LIMIT 1) AS filename, (SELECT originalname FROM products_files WHERE active = 1 AND type="pictures" AND parent_id = p.id ORDER BY priority ASC LIMIT 1) AS image_originalname FROM products AS p WHERE p.popular = 1 AND p.active = 1 AND (p.virtual = 0 OR p.virtual = 1) AND p.id IN (SELECT CONCAT(product_id) FROM products_categories WHERE category_id=) GROUP BY IF(p.code_group!="",p.code_group,p.id) LIMIT 0,4