SQL Statement Bulk update data (Multi-Table Association)

Source: Internet
Author: User

Recently encountered a problem in the project, the original design function is not required a specific field value depid, but the new features need to be based on depid to show, so there is a problem, the new added data have the correct depid, And the original large amount of data there is no depid or said depid not want to, facing the problem of batch update the original data depid.

The update involves three table Base_cooperativegroup,base_groupuser,base_user.

List the table structure:

1.base_cooperativegroup

2.base_groupuser

3.base_user

The update statements are as follows:

set base_cooperativegroup.depid=d.dwbh from (select from base_ Groupuser left join Base_user on Base_groupuser.useridwhere base_groupuser.isleader='1  '  ) dwhereisnull and  Base_ Cooperativegroup.groupid=d.groupid

OK, finished.

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.