[英]Column concatenation returns “Null” Mysql - Php
I can able to concatenate the values using the following code 我可以使用以下代码连接值
$sqlselect = "UPDATE billing_details SET SRF = CONCAT(Year, ID)";
but it returns the result value as "NULL". 但它返回的结果值为“ NULL”。 Kindly help me to solve this issue
请帮助我解决这个问题
Table Structure: 表结构:
Year *Varchar(5)*
ID *Int(10)*
SRF *Varchar(100)*
Result Table: 结果表:
MySql CONCAT function is return NULL
if any argument value if null value, see blow 如果有任何参数值,则MySql CONCAT函数将返回
NULL
,如果为空值,请参见打击
SELECT COCAT(NULL, 1)
SELECT COCAT(1, NULL)
>NULL
If you want to keep other values while any argument value have null then use IFNULL() function to exclude NULL values 如果要在其他任何参数值都为null的同时保留其他值,请使用IFNULL()函数排除NULL值
In your query 在您的查询中
$sqlselect = "UPDATE billing_details SET SRF = CONCAT(IFNULL(Year, ''), IFNULL(ID, ''))";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.