IF Statements in MySQL, Conditional Logic

There are two different options when thinking of IF statements in MySQL

  1. SELECT IF() function — Given a boolean expression, it returns a value depending on the result of the boolean expression
  2. IF statement — Given a boolean expression, it executes a certain block of code, depending on the result of the boolean expression. Can only be used inside a stored procedure.

SELECT IF() Function

Syntax