webCOMAND

IF()

Return the result of one expression if a condition is true, and another if it is false.

Prototype

mixed IF(expression condition, expression true, expression false)

Parameters

  • condition - Expression to evaluate to TRUE or FALSE.
  • true - Expression to evaluate and return if condition evaluates to TRUE.
  • false - Expression to evaluate and return if condition evaluates to FALSE.

Return

Result of the true expression if a condition is TRUE, and the false expression if the condition is FALSE.

Example

SELECT OID, IF(OID=123,'Yes','No') AS Is123 FROM User

Related

IFNULL(), ISNULL()