If and Else control structure works only inside of a procedure. MySQL IF Statement - MySQL Tutorial MySQL IF-THEN -ELSE statement In case you want to execute other statements when the condition in the IF branch does not evaluate to TRUE, you can use the IF-THEN -ELSE statement as follows: 1. MySQL IF ELSE statement implements a basic conditional construct when the expression evaluates to false. There is no corresponding ELSEIF function or END IF keyword. So if you are creating a procedure and you want to use if and else control structure in your stored procedure. If no comparison or condition is true, the result after ELSE is returne or NULL if there is no ELSE part.
Depending on the context in which it is use it returns either numeric or string value.
The second syntax returns the result for the first condition that is true. Its syntax is as follows:IF expression THEN state. IF in MySQL is a ternary function, not a control structure - if the condition in the first argument is true, it returns the second argument otherwise, it returns the third argument.