UPDATE statement: the statement used to UPDATE fields in one table to fields in another table.

Source: Internet
Author: User
Tags mssql server

UPDATE statement: the statement that updates the fields in one table to the fields in another table adds a field to a table in one table in the modification of the result query system, now we need to copy the corresponding ID of another table. because such SQL operations are not often used, we even think of writing a loop for processing. However, I thought that SQL should be able to implement such a function. I checked the manual and it was really simple. There was a syntax for updating... from. Example: Table Aid subject_id1 null2 null3 null4 null5 null6 null table Bsb_id st_id5 12 25 35 42 52 6SQL statement: 1UPDATEASETA. subject_id = B. sb_idFROMBWHEREB.student_id =. id update: The preceding statement is only applicable to mssql server. The following statement should be used in mysql: 1 UPDATEA, BSETA. subject_id = B. sb_idWHEREB.student_id =. id Example 2: MYSQL is the update table2 B, (select B. area_id as arid, sum (. user_amount) as bcountfrom table1 a, table2 bwhere. user_area = B. area_idgroup by ari D) cset B. count = c. bcountwhere B. area_id = c. arid; a dedicated MYSQL instance is installed for testing and passes the test.

Related Article

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.