Workaround for the MySQL Concat() Returns NULL if Any Fields Are NULL Problem

In MySQL the CONCAT funcation returns NULL if any of the concated fields are NULL, who knew? - so even if all the fields except 1 have valid data it will return NULL - aparrently this is a feature

if your stuck on this the workaournd is to put an IFNULL in the field, refer example below:

1
SELECT CONCAT(IFNULL(fName1,''),' ',IFNULL(mName2,''),' ',IFNULL(lName3,'')) AS userName

or use CONCAT_WS - which allows for null - but requires a seperator to be defined