Php append data to mysql

Source: Internet
Author: User
Tags php mysql
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.