bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL IF() Function

Example

SELECT
IF(500<1000, "YES", "NO");

Definition and Usage

The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

Syntax

IF(
condition
,
value_if_true
,
value_if_false
)

Parameter Values

ParameterDescription
conditionRequired. The value to test
value_if_trueRequired. The value to return if condition is TRUE
value_if_falseRequired. The value to return if condition is FALSE

Technical Details

Works in:From MySQL 4.0

Previous

MySQL DATABASE() Function

Next

MySQL IFNULL() Function