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)