Flow Control

MySQL flow control functions can be used to query given columns and return results for a field based on the results of the column query.

CASE

This MySQL function produces results that vary based on which condition is true. It is similar to the IF( ) function except that multiple conditions and results may be strung together.

This MySQL function returns the result given in the second argument if the condition given in the first argument is met (i.e., the condition does not equal 0 or NULL). If the condition does equal 0 or NULL, the function returns the result given in the third argument.

IFNULL( )

This MySQL function returns the results of the condition given in the first argument of the function if its results are not NULL. If the condition results are NULL, the results of the expression or string given in the second argument are returned.

ISNULL( )

Use this MySQL function to determine whether the value of the argument given in parentheses is NULL. It returns 1 if the value is NULL and 0 if it is not NULL.

NULLIF( )

This MySQL function returns NULL if the two arguments given are equal. Otherwise, it returns the value or results of the first argument.