#案例:选中city在多伦多工作的员工 SELECT last_name,job_id,e.department_id,department_name FROM employees
#案例:选中city在多伦多工作的员工
SELECT
last_name,job_id,e.department_id,department_name
FROM
employees AS e,departments AS d,locations AS l
WHERE
e.`department_id`=d.`department_id`
AND
d.`location_id`=l.`location_id`
AND
l.city='Toronto'
#案例;查询每个国家下的部门个数大于2的国家编号
SELECT
country_id ,COUNT(*)
FROM
locations AS l,departments AS d
WHERE
l.`location_id`=d.`location_id`
GROUP BY
country_id
HAVING
COUNT(*) >2;
--结束END--
本文标题: mysql 多表查询案例
本文链接: https://lsjlt.com/news/45549.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0