First page Back Continue Last page Image

A Stored Procedure IF Statement

IF boolean_expression THEN

code_to_run_if_true;

ELSEIF boolean_expression THEN

code_to_run_if_true;

ELSE

code_to_run_if_false;

END IF;

Boolean expressions always return either a “True” or a “False”

Here is the format or Syntax for a MySQL Stored Procedure IF Statement

Boolean Expression Examples

field = 0

field IS NULL

field > 200

field = ‘exception’

field = ‘One’ OR field = 1

TRUE

FALSE

If no condition is True, then this will happen