Multi-table joins
# Multi-table queries / * sql199 standard equivalent connections ① The results in Table equijoins plurality of multi-table intersection portion ② n connections requires at least n-1 connections ③ aliases table typically requires ④ can be used with all the previously described use clause, such as sorting, grouping, filtering * / - 1. the query has the bonus of staff name, department name the SELECT last_name, department_name, commission_pct the FROM the employees E, the departments d the WHERE e.`department_id` = d.`department_id` the aND e.`commission_pct` iS the NOT NULL ; - 2. query cities o the second character is the city department and the SELECT department_name, city the FROM the departments d, locations L the WHERE d.`location_id` = l.`location_id` the AND City the LIKE ' %% _O ' ; - 3. The number of sectors in each city query the SELECT COUNT ( * ) number, City the FROM Departments D, L locations the WHERE D. location_id` ` = l.`location_id` the GROUP BY City; - 4. query the minimum wage department name and department heads of each department's leadership bonus number and the sector the SELECT d.department_name, d.manager_id, MIN ( the salary) the FROM Departments D, E the Employees the WHERE d.`department_id` = e.`department_id` the ANDcommission_pct IS the NOT NULL the GROUP BY d.department_name, d.manager_id; - query name and the number of employees working in jobs of each employee, and the number of employees in descending order by the SELECT JOB_TITLE, COUNT ( * ) the FROM the Employees E, J Jobs the wHERE e.`job_id` = j.`job_id` the GROUP BY JOB_TITLE the ORDER BY COUNT ( * ); # achieve three-table join - inquiry staff name, department name and the city where the SELECT last_name, department_name, city the FROM the employees E, the departments d , locations L the WHERE e.`department_id`= d.`department_id` AND d.`location_id` = l.`location_id` AND city LIKE '%s%';