目录
1.查询“Chisel”所在车间的车间编号、车间主任姓名、主任联系方式
2.查询所有员工姓名、员工联系电话、车间地址、车间主任姓名、主任联系方式
3.查询“Chisel”所在车间的所有员工姓名、员工联系电话、车间地址
4.查询生产出质量达标产品的产品编号、员工姓名、员工联系电话
6.查询所有产品的产品编号、是否合格(合格返回true不合格返回false)、员工号、员工姓名、员工联系方式、车间编号、车间地址
7.查询员工表中是否存在“common”工种的员工,如果存在则查询员工表“common”工种员工的所有字段信息
8.查询存在离职员工的车间编号、车间主任、主任联系方式
1.查询“Chisel”所在车间的车间编号、车间主任姓名、主任联系方式
select no,name,phone from zhongjinlin_workshop ws
-> where no in (
-> select shop_no from zhongjinlin_worker
-> where name="Chisel"
-> );
2.查询所有员工姓名、员工联系电话、车间地址、车间主任姓名、主任联系方式
select wk.name,wk.phone,ws.address,ws.name,ws.phone from
-> zhongjinlin_worker wk right join zhongjinlin_workshop ws on
-> wk.shop_no = ws.no;
3.查询“Chisel”所在车间的所有员工姓名、员工联系电话、车间地址
select shop_no from zhongjinlin_worker
-> where name="Chisel";
select wk.name,wk.phone,ws.address from
-> zhongjinlin_worker wk inner join zhongjinlin_workshop ws
-> on wk.shop_no = ws.no where shop_no = "WS1";
4.查询生产出质量达标产品的产品编号、员工姓名、员工联系电话
select no,name,phone from zhongjinlin_worker where
-> is_onwork="1";
5.查询已生产产品车间的车间号、平均工龄
select shop_no,avg(seniority) from zhongjinlin_worker where shop_no = "WS2";
6.查询所有产品的产品编号、是否合格(合格返回true不合格返回false)、员工号、员工姓名、员工联系方式、车间编号、车间地址
select pd.no,pd.is_qualified,wk.no,wk.name,wk.phone,ws.no,ws.address from
-> zhongjinlin_product pd
-> right join zhongjinlin_worker wk on pd.work_no =wk.no
-> left join zhongjinlin_workshop ws on pd.work_no = ws.no;
7.查询员工表中是否存在“common”工种的员工,如果存在则查询员工表“common”工种员工的所有字段信息
select * from zhongjinlin_worker where
-> work_type="common";
8.查询存在离职员工的车间编号、车间主任、主任联系方式
select no,name,phone from zhongjinlin_workshop
-> where no in(
-> select shop_no from zhongjinlin_worker
-> where is_onwork="0"
-> );