MySQL SQL

MySQL CASE

Return conditional values from a query.

SELECT name,
CASE WHEN price >= 1000 THEN 'Premium'
     WHEN price >= 500 THEN 'Standard'
     ELSE 'Budget' END AS tier
FROM products;

WHEN conditions are checked in order and the first matching result is returned.