CASE with condition : CASE : Control Flow Functions MySQL TUTORIALS


MySQL TUTORIALS » Control Flow Functions » CASE »

 

CASE with condition


CASE WHEN [conditionTHEN result
    [WHEN [conditionTHEN result ...]
    [ELSE result]
END

Return the result for the first condition that is true.

If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.

mysql>
mysql> SELECT CASE
    ->        WHEN 1>THEN 'true'
    ->        ELSE 'false'
    -> END;
+-------------------------------------------------------------+
| CASE
       WHEN 1>THEN 'true'
       ELSE 'false'
END |
+-------------------------------------------------------------+
true                                                        |
+-------------------------------------------------------------+
row in set (0.00 sec)

mysql>
mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Control Flow Functions
» CASE