SELECT * FROM tbl_product WHERE status=1 AND `cat_id` = ORDER BY CASE WHEN `priority` = 0 THEN 'a' END , priority ASC LIMIT 0, 20