当前位置:网站首页>MySQL winter vacation self-study 2022 11 (10)

MySQL winter vacation self-study 2022 11 (10)

2022-07-05 03:13:00 Crane paper thousand

--  practice 
-- 1, Return the name of the Department that owns the employee , Department number 
select distinct dname,dept.deptno from dept join emp on dept.deptno = emp.deptno;

-- 2, Pay more than smith Employee information 
select * from emp where sal > (select sal from emp where ename = 'smith');

-- 3, Return the employee's name and manager 
select a.ename,b.ename from emp a  join emp b on a.mgr = b.empno;

select a.ename,b.ename from emp a,emp b where a.mgr = b.empno; 

-- 4, Return the name of the employee and his / her manager whose employment date is earlier than that of his / her manager 
select a.ename,a.hiredate,b.hiredate,b.ename from emp a  join emp b on a.mgr = b.empno and a.hiredate<b.hiredate;

Let's start with this , Too sleepy , Make up tomorrow

原网站

版权声明
本文为[Crane paper thousand]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140803353484.html