Php append data to mysql append data to php mysql
Php append data to mysql
In mysql, a table user has a name field.
The table already has a record.
The id field value is 1.
The value of the name field is "week"
Now I want to append the word "marker" to this field.
That is, let the name field value of this record change from the original "week" to the current "Jay Chou"
What should I do?
How to write code?
Code
$ SQL = "update user set name = name + 'hangzhou' where id = '1 '";
Mysql_query ($ SQL );
In the future, the value of the name field becomes "0.
Reply to discussion (solution)
Dizzy
This is the case.
$ SQL = "update user set name = concat (name, 'hangzhou') 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 directly changed the name field to "Jay Chou,
Instead of appending "week" to the end of "week.
Different methods,
In actual applications, it cannot achieve the same effect.
Use concat.