SQL Association operations (Query and update)

Source: Internet
Author: User

    sql In addition to the associated query, you can also associate update deletion, and sometimes a SQL to take care of data migration,  avoid writing stored procedures. The following is a list of the various cascading operations scenarios for SQL.         Main Table: Department table-dept (Dept_id,dname,enum)        From table: Employee table-emp  (emp_id , ename , sal,dept_id)       // Here is the SQL syntax  1 for Oracle, associated queries      scenarios: Querying the department name of all employees                     2, related updates      Scenario: Number of people updating departmental tables enum           update dept d  set d.enum =               ( Select count (*)  from emp e    where e.dept_id=d.dept_id );   3, correlated subqueries      scenario A: Which employees pay-sal  higher than the average wage in the Department                scene B: IsolatedNo employee department           4, associated deletions      scenes: Delete departments without employees 

Note: The above blog post was moved from my open source China.

This article is from the "Wangxu_java" blog, make sure to keep this source http://wangxujava.blog.51cto.com/4277921/1712936

SQL Association operations (Query and update)

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.