当原始字段为空时,sql concat

时间:2022-08-26 07:57:51

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:

我试图在一个字段上运行CONCAT,它可能是空的,也可能不是空的。如果场不是空的,就没有问题,即如果库仑A中的场等于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'?

给a_b。问题是,如果列A中的字段为空,则concat将不返回任何内容。是否有一种方法可以将字段连接起来,即使该字段是空的,在本例中,该字段将返回'_b'?

1 个解决方案

#1


5  

In Sql server

在Sql server

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

Use IFNULL in Mysql.

在Mysql中使用IFNULL。

Refer different function as per different database

根据不同的数据库引用不同的功能

#1


5  

In Sql server

在Sql server

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

Use IFNULL in Mysql.

在Mysql中使用IFNULL。

Refer different function as per different database

根据不同的数据库引用不同的功能