mysql> select * from employee;
mysql> select * from employee limit 5;
mysql> select name,addr,tel from employee ;
select name,addr,tel from employee where num=001;
mysql> select name,addr as 地址,tel as 电话 from employee where sex='女';
mysql> select num,inCome-outCome as 实际收入 from salay;
mysql> select distinct depno,name from employee where name like '王%';
mysql> select num from salay where (inCome-outCome)>2000 and (inCome-outCome)<3000;
select * from employee where depno=(select depno from department where depName='财务部');
select name from employee where depno in( select depno from department where depName='财务部' and birth < all( select birthh from employee where depno in( select depno from department where depName='研发部')));
SELECT name FROM employee WHERE depno IN(
SELECT depno FROM salay WHERE inCome>ALL(
SELECT inCome FROM salay WHERE depno IN(
SELECT depno FROM employee WHERE depno=(
SELECT depno FROM department WHERE depName='财务部'))));
SELECT e.*,s.* FROM employee e
INNER JOIN salay s
ON e.num=s.num;
SELECT e.name, s.* FROM salay s
INNER JOIN employee e
ON s.Num =e.Num
INNER JOIN department d
ON e.depno=d.depno
WHERE s.income>2200 AND d.depname='财务部';
select avg(inCome-outCome) as 财务部平均实际工资 from employee e inner join salay s on s.num=e.num inner join department d on d.depno=e.depno where d.depName='财务部'group by e.depno;
mysql> select sum(e.depno) as 财务部总人数 from employee e inner join salay s on s.num=e.num inner join department d on d.depno=e.depnoo where d.depName='财务部'group by e.depno;
mysql> select d.depno,d.depName,sum(e.depno) from employee e inner join department d on d.depno=e.depno group by depno;
select d.depno,d.depname,avg(s.income) from employee e inner join department d on d.depno=e.depno inner join salay s on s.num=e.num group by e.depno having avg(s.inCome)>2500;