
# 查询比“张无忌”的工资高
## 查询张无忌工资
## 查询工资大于张无忌工资值
SELECT * FROM emp,salary 
WHERE emp.stid=salary.stid 
AND salary.salarystid > 
(SELECT salary.salarystid 
FROM emp,salary WHERE emp.stid=salary.stid AND emp.ename='fuck')

#查询和张无忌同一个部门
SELECT emp.`ename` FROM emp,dept 
WHERE emp.`edid`=dept.`did`
AND dept.`dname`=(SELECT dept.`dname`
FROM emp,dept WHERE dept.`did`=emp.`edid` AND emp.`ename`='jack')
# 统计每个部门有多少个员工()里面的是临时表
SELECT dept.dname,es.num FROM dept,(SELECT COUNT(*) AS num,edid FROM emp GROUP BY edid) es
WHERE dept.did=es.edid
