sql concat when original field is empty

concatenation, sql

Solution

In Sql server

SET A = CONCAT(isnull(A,''), '_b')

Use `IFNULL` in Mysql.

Refer different function as per different database

Problem

I'm trying to run CONCAT on a column with fields that may or may not be empty. If the field isn't empty, there is no problem, i.e. if field in coulmn A equals a: ``` SET A = CONCAT(A, '_b') ``` gives a_b. The problem is, if the field in column A is empty, the concat returns nothing. Is there a way for it to concatenate even if the field is empty, which, in this example, would return '_b'?

Original source