Append data php mysql
PHP Append data to MySQL
In MySQL, a table in user has a field in name
There is already a record in the table
ID field value is 1
The value of the name field is "Week"
I now want to append "Jay" two words to this field
That is, the value of the name field of this record from the original "Week" Into the present "Jay"
How would you like to operate it?
How do I write code?
In code
$sql = "Update user set name = name + ' Jay ' where id= ' 1 '";
mysql_query ($sql);
The value of the Name field later becomes "0".
Reply to discussion (solution)
Dizzy Death
It turns out that.
$sql = "Update user set Name=concat (name, ' Jay ') where tid= ' 1 '";
mysql_query ($sql);
$sql = "Update user set name = ' Jay Chou ' where id= ' 1 '";
$sql = "Update user set name = ' Jay Chou ' where id= ' 1 '";
You're just going to change the name field to "Jay Chou".
Instead of appending "Jay" to the back of "Week".
method is not the same,
To the actual application can not play the same effect.
Well, then use Concat.