Copy SQL statements for two field data in a database table _ database Other

Source: Internet
Author: User
Tags numeric value
To copy a SQL statement from two field data in a database table

Add a new field to the table today, but want to be the same as another field in the table, because the data is too much to be implemented through the SQL statement, the following sentence is really useful.

Copy Code code as follows:

Update Jb51_temp Set B=a


Jb51_temp indicates that a is a field with a numeric value, B is a newly added field, remember to put the null table in front, if the set a=b, then your values are empty, it's troublesome to back up the database before recommending the operation.


How to add a value in a field to another field

For example, there are two fields A and B,a fields is the value is "I", b field value is "we", how to use the UPDATE statement to copy the value of B field to a, and a combination to put the original content behind. After the update a field should be "we", the B field is unchanged.

Copy Code code as follows:

Update table Set A=a+b

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.