bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL IF() Function

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind MySQL IF() Function?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

IF(500<1000, "___", "NO");
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
Definition and Usage
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