mysql coalesce

Solutions on MaxInterview for mysql coalesce by the best coders in the world

showing results for - "mysql coalesce"
Andrew
27 Jan 2021
1#Avoid sum null
2SELECT SUM(COALESCE(field_with_null_values, 0)) as s FROM tablename
3
4#Avoid concat string null
5SELECT CONCAT(name_never_null, ' ', COALESCE(surname_with_null_values, '')) as complete_name FROM users
6
Luca
15 Jul 2016
1The COALESCE() function returns the first non-null value in a list.
2
3Example : SELECT COALESCE(NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
4
5output : 'W3Schools.com'