9.24mysql
作者:互联网
-- 子查询 把查询的结果当作另一个的查询条件
-- 查询开发部所有员工信息
SELECT * FROM emp01 WHERE did=(SELECT did FROM dept01 WHERE dname='开发部')
-- 查询所有女员工所属部门名称
SELECT dname FROM dept01 WHERE did=(SELECT did FROM emp01 WHERE esex='女')
-- 查询男员工所属部门经理
SELECT mgr FROM dept01 WHERE did IN(SELECT did FROM emp01 WHERE esex='男')
SELECT did,dname FROM dept01 UNION SELECT eid,ename FROM emp01
标签:emp01,9.24,did,查询,--,mysql,WHERE,SELECT 来源: https://www.cnblogs.com/jiangliangliang/p/15336713.html