CASE WHEN in MySQL — How It Works

What the MySQL CASE WHEN function does, with an example.

Published October 22, 2026

CASE WHEN evaluates multiple conditions in order and returns the value for the first one that matches.

Key points

  • Part of standard SQL functions available in MySQL for working with query results

Example

SELECT CASE WHEN score >= 90 THEN 'A' WHEN score >= 80 THEN 'B' ELSE 'C' END FROM grades;
More SQL articles