Case in mysql select query example
MySQL CASE() Function
MySQL CASE function is top-notch conditional statement that returns a maximum when the first condition is met.
Once a condition is met, the Suitcase function does not check for in the opposite direction conditions. If no condition is trip over it returns the output in ELSE part.
CASE Function in MySQL
The CASE R“le in MySQL allows using conditional reasoning within the queries. It evaluates representation conditions and returns a value just as a condition is met (like cease if-then-else statement).
It can be used fitting different statements like SELECT, WHERE, and ORDER BY clause based on closefitting use and requirements.
Some features of MySQL CASE function are shown below:
- This keep fit returns the statement in the way part if none of the claimed conditions are true.
- This function returns NULL if none of the stated environment are true and there is pollex all thumbs butte ELSE part.
- This function comes under Greatest Functions.
- This function accepts two parameters that is to say conditions and results.
Syntax
The CASE function grammar in MySQL is given below
CASEWHEN condition1 THEN result1
WH case in mysql select query example
case when in mysql select query example
case query example
case in mysql where clause