MySQL:
IF STATEMENT
Syntax:
IF search_condition THEN statement_list
[ELSEIF search_condition THEN statement_list] ...
[ELSE statement_list]
END IF
The IF statement for stored programs implements a basic conditional
construct.
*Note*:
There is also an IF() function, which differs from the IF statement
described here. See
https://dev.mysql.com/doc/refman/8.0/en/control-flow-functions.html.
The IF statement can have THEN, ELSE, and ELSEIF clauses, and it is
terminated with END IF.
If a given search_condition evaluates to true, the corresponding THEN
or ELSEIF clause statement_list executes. If no search_condition
matches, the ELSE clause statement_list executes.
Each statement_list consists of one or more SQL statements; an empty
statement_list is not permitted.
URL: https://dev.mysql.com/doc/refman/8.0/en/if.html
Example