2.2.2. CASE- / IF-Konstrukte

Data Retrieval Language

CASE
CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result …] [ELSEresult] END
oder
CASE WHEN [condition] THEN result [WHEN [condition] THEN result …] [ELSE result] END

IF
IF(expr1,expr2,expr3)
If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3.

IFNULL
IFNULL(expr1,expr2)
If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.

NULLIF
NULLIF(expr1,expr2)
Returns NULL if expr1 = expr2 is true, otherwise returns expr1.