There is a request:

SELECT p.product_id, (SELECT AVG(rating) AS total FROM review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN product_tag pt ON (p.product_id = pt.product_id) WHERE pd.language_id = '2' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND ( LCASE(pd.name) LIKE '%24%' OR LCASE(pt.tag) LIKE '%24%' AND pt.language_id = '2') or pd.product_id = '24' LIMIT 0,15 

Is it possible to display the first line found by the condition pd.product_id = '24' if it is?

  • 2
    order by if(pd.product_id = 24, 0, 1) - Mike
  • Thanks, it works like this - Jonny Manowar

0