Use case when : CASE WHEN Select « Flow Control « SQL / MySQL






Use case when

/*
mysql>   SELECT CASE WHEN 9>7
    ->                  THEN "TRUE"
    ->                  ELSE
    ->                  "FALSE"
    ->                  END
    ->   AS "Results";
+---------+
| Results |
+---------+
| TRUE    |
+---------+
1 row in set (0.00 sec)


*/

  SELECT CASE WHEN 9>7 
                 THEN "TRUE" 
                 ELSE 
                 "FALSE" 
                 END 
  AS "Results";

           
       








Related examples in the same category

1.Use CASE WHEN for string value
2.Simple CASE WHEN command
3.CASE WHEN with calculation
4.Use CASE WHEN statement in SELECT
5.Use CASE WHEN statement in SELECT 2