列串联返回“ Null”。 MySQL-PHP

问题描述:

我可以使用以下代码来连接值

I can able to concatenate the values using the following code

$sqlselect = "UPDATE billing_details SET SRF = CONCAT(Year, ID)";

,但返回的结果值为 NULL。请帮助我解决此问题

but it returns the result value as "NULL". Kindly help me to solve this issue

表结构:

Year *Varchar(5)*

ID *Int(10)*

SRF *Varchar(100)*

结果表:

MySql CONCAT函数返回 NULL 如果有任何参数值(如果为空值),请参见打击

MySql CONCAT function is return NULL if any argument value if null value, see blow

SELECT COCAT(NULL, 1) 





OR

SELECT COCAT(1, NULL)

> NULL

如果您想在其他参数值都为null的同时保留其他值,请使用IFNULL()函数排除NULL值

If you want to keep other values while any argument value have null then use IFNULL() function to exclude NULL values

在查询中 >

$sqlselect = "UPDATE billing_details SET SRF = CONCAT(IFNULL(Year, ''), IFNULL(ID, ''))";