SQL multi-table query to eliminate duplicate content in a table

Source: Internet
Author: User

See a friend write another SQL statement: Two tables A1 table has SN, SN2, TN,B1 table has SM, SM2, TN2, if the data in the SN of A1 and B1 of the data in the SM is consistent, then the corresponding data in A1 is modified to the corresponding data in B1.

Update a1 Set SN2 = (select B1. SM2 from B1 where A1. SN = B1. SM), TN = (select B1. TN2 from B1 where A1. SN = B1. SM) where  A1. SN in (select Smfrom B1);

SQL multi-table query to eliminate duplicate content in a table

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.