in mysql query with coalesce code example
Example 1: mysql coalesce
#Avoid sum null
SELECT SUM(COALESCE(field_with_null_values, 0)) as s FROM tablename
#Avoid concat string null
SELECT CONCAT(name_never_null, ' ', COALESCE(surname_with_null_values, '')) as complete_name FROM users
Example 2: coalesce mysql
The COALESCE() function returns the first non-null value in a list.
Example : SELECT COALESCE(NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
output : 'W3Schools.com'