笔记中from后面的子查询得到的结果必须是多条记录 感觉不是很妥当
select empno 员工号,ename 姓名,sal 月薪,sal*12 年薪
from (select * from emp where ename='KING') e;
select empno 员工号,ename 姓名,sal 月薪,sal*12 年薪
from (select * from emp where ename='KING') e;
2017-01-11
mysql 左外连接:
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from dept d left join emp e
on d.deptno=e.deptno
group by d.deptno,d.dname;
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from dept d left join emp e
on d.deptno=e.deptno
group by d.deptno,d.dname;
2017-01-10
右外连接 :(取右表的全部)
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from emp e,dept d
where e.deptno(+)=d.deptno
group by d.deptno,d.dname;
左外连接:(取左表的全部)
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from dept d,emp e
where d.deptno=e.deptno(+)
group by d.deptno,d.dname;
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from emp e,dept d
where e.deptno(+)=d.deptno
group by d.deptno,d.dname;
左外连接:(取左表的全部)
select d.deptno 部门号,d.dname 部门名称,count(e.empno) 人数
from dept d,emp e
where d.deptno=e.deptno(+)
group by d.deptno,d.dname;
2017-01-10