top of page
CerebroSQL

IF STATEMENT

База данных: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

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

bottom of page