bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL COALESCE() Function

Concept visual

MySQL COALESCE() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Formula

Return the first non - null value in a list:

Select

COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');

Definition and Usage

Formula

The COALESCE() function returns the first non - null value in a list.

Syntax

Coalesce(

val1, val2,...., val_n )

Parameter Values

Parameter

Description val1, val2, val_n Required. The values to test

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

Formula

Return the first non - null value in a list:

Select

COALESCE(NULL, 1, 2, 'W3Schools.com');

Previous

❮ MySQL Functions

Next

Previous

MySQL CAST() Function

Next

MySQL CONNECTION_ID() Function