Query & Priority

Viewed 21

I want to list manufacturers with the category priority (if category: 1 => list first)

I tried the mysql query at below but getting syntax error. Could someone help me?

SELECT 
  name, category, id 
  CASE WHEN category = '1' THEN 1 WHEN category = '3' THEN 2 END AS ordering_field 
FROM manufacturers 
ORDER BY ordering_field

ERROR CODE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE WHEN category = '1' THEN 1 WHEN category = '3' THEN 2 END AS ordering_field' at line 1

0 Answers
Related