目录

MySQL COALESCE() Function

❮ MySQL Functions

Example

Return the first non-null value in a list:

SELECT COALESCE(NULL, NULL, NULL, '91xjr.com', NULL, 'Example.com');
Try it Yourself »

Definition and Usage

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

Return the first non-null value in a list:

SELECT COALESCE(NULL, 1, 2, '91xjr.com');
Try it Yourself »

❮ MySQL Functions