MySQL ifNull()
I didn’t find an answer to this in my first few google search results, so I’m posting it here.
When using CONCAT() in MySQL, if any of the values are NULL, then the CONCAT fails and the return is NULL. BQW told me about NVL(), which is Oracle/PGSQL (so useless for me), but that led me to IFNULL(). IFNULL(statement, return): If ’statement’ is null, ‘return’ is returned. Simple use can be IFNULL(fieldName, “”), which will fit nicely into a concat. It actually worked much better in my case, allowing me to do some conditional output formatting.