COALESCE()
is a function that returns the first value that is not null within a list.
Structure
SELECT COALESCE(value1, value2, value3, ...)
;
Examples
SELECT COALESCE(NULL, 'a', 1, NULL)
; //a
SELECT COALESCE(NULL, NULL, NULL, 'b')
; //b
Published by Muhammad Asfour
Estimated reading time: 1 min
COALESCE()
is a function that returns the first value that is not null within a list.
SELECT COALESCE(value1, value2, value3, ...)
;
SELECT COALESCE(NULL, 'a', 1, NULL)
; //a
SELECT COALESCE(NULL, NULL, NULL, 'b')
; //b