SQL update two tables and update corresponding field values to implement _access

Source: Internet
Author: User
Tags one table
ACCESS
Example:
Copy Code code as follows:

INSERT into the products (Pronumber,casnumber,cnname,price,enname,baozhuang,pinpai) Select Pronumber,casnumber,cnname, Price,enname,baozhuang,pinpai from product22

1. Remove data from one table into another table with SQL. This is useful for data conversion between different programs, and is fast and complete:
Insert INTO table1 (column1,column2,...) Select Column1,column2,... from table2
(where Table1 's fields correspond to table2, mainly data types, and the number of fields must be equal)
2. Use one SQL to retrieve the data from a table to update the corresponding values in another table:
Copy Code code as follows:

Update table1,table2 set table1.column1=table2.column1 where Table1.column2=table2.column2

Just like the last one, it has to correspond. You can also extend updates to the corresponding values between multiple tables.
3. Compare the values of a corresponding field in two tables:
Copy Code code as follows:

SELECT * FROM table1 where ID isn't in (select ID from table2)

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.