#(1)请写出要查询员工J开头的名字其工号(EMPNO)及部门名称(DEPTNA)的 SQL语句SELECT e.emp,e.name,d.deptna FROM emp e left join dept d on d.deptno =e.deptno where e.name like 'J%'#(2)请写出要查询 Kevin 所在部门的部门代号(DEPTNO)及部门名称(DEPTNA)的 SQL 语句SELECT e.name,d.deptno,d.deptna FROM emp e left join dept d on d.deptno =e.deptno where e .name = 'kevin'#(3)请使用多表查询(JOIN),写出要查询所有员工,包含没有部门的 SQL 语句SELECT e.name,d.deptna FROM emp e left join dept d on d.deptno =e.deptno#(4)请使用多表查询(JOIN),写出要查询有员工没有部门,以及有部门没有员工的 SQL语句SELECT e.name,d.deptna FROM emp e LEFT JOIN dept d ON e.deptno = d.deptnoWHERE d.deptno IS NULLUNION SELECT e.name,d.deptna FROM dept dLEFT JOIN emp e ON e.deptno = d.deptno WHERE e.deptno IS NULL
#dept org#(1)请写出要查询部门MIS下属的所有部门的SQL 语句SELECT d.deptno, d.deptna
FROM dept d
INNER JOIN org o ON d.deptno = o.child_deptno
INNER JOIN dept p ON o.parent_deptno = p.deptno
WHERE p.deptna = 'MIS';#(2)请写出要查询部门ERP 上层的所有部门的 SQL 语句SELECT d.*
FROM dept d
INNER JOIN org o ON d.deptno = o.parent_deptno
INNER JOIN dept p ON o.child_deptno = p.deptno
WHERE p.deptna = 'ERP';