coalesce mysql

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

showing results for - "coalesce mysql"
Reggie
25 Aug 2020
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
Ewenn
24 Mar 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'