Reputation: 25
I want to insert two column values(Year + ID(Primarykey-AutoIn) = SRF) in to one column
i can able to concatenate the values using the following code SELECT CONCAT(Year, ID) AS SRF FROM billing_details
but i dont know how to insert those values in a column namely "SRF".
Updated Question:
Now i have used the following code
$sqlselect = "UPDATE billing_details SET SRF = CONCAT(Year, ID)";
it returns as "Null"
Upvotes: 1
Views: 869
Reputation: 25
The issue has been resolved by using the following code courtesy to Mr.Girish (Column concatenation returns "Null" Mysql - Php) and other sweet supporters(Akond, Mureinik, Jens, Valentin Rusk and etc "Thank you all for giving valuable support" )
//Concatenation of Year+ID=SRF
$sqlselect = "UPDATE billing_details SET SRF = CONCAT(`Year`, `ID`)";
if (!mysqli_query($con,$sqlselect)) {
die('Error: ' . mysqli_error($con));
}
Upvotes: 0
Reputation: 311163
You first need to add the column to your table, assuming it does not exist yet:
ALTER TABLE billing_details ADD COLUMN srf VARCHAR(100);
And then use an update
statement:
UPDATE billing_details
SET srf = CONCAT(year, id);
Upvotes: 0