问题
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". Kindly help me to solve this issue
Table Structure:
Year *Varchar(5)*
ID *Int(10)*
SRF *Varchar(100)*
Result Table:
Year Id SRF
A 1 NULL
A 2 NULL
A 3 NULL
回答1:
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
If you want to keep other values while any argument value have null then use IFNULL() function to exclude NULL values
In your query
$sqlselect = "UPDATE billing_details SET SRF = CONCAT(IFNULL(Year, ''), IFNULL(ID, ''))";
来源:https://stackoverflow.com/questions/26711668/column-concatenation-returns-null-mysql-php