设有一个设有一个SPJ数据库,包括S,P,J,SPJ四个表
(1) 供应商表S由供应商代码(SNO)、供应商姓名(SNAME)、供应商状态(STATUS)、供应商所在城市(CITY)组成;
(2) 零件表P由零件代码(PNO)、零件名称(PNAME)、颜色(COLOR)、重量(WEIGHT)所组成;
(3) 工程项目表J由工程项目代码(JNO)、工程项目名称(JNAME)、工程项目所在城市(CITY)组成;
(4) 供应情况表SPJ由供应商代码(SNO)、零件代码(PNO)、工程项目代码(JNO)、供应数量(QTY)所组成;表示某供应商供应某种零件给某工程项目的数量为QTY。
请设计上述四张表,完成如下题目:
1. 查询所在城市为上海的所有工程全部信息
2. 取出重量最轻的零件代号
3. 查出为工程J1提供零件的供应商代号
4. 查出为工程J1提供零件P1的供应商代号
5. 查询由供应商S1提供零件的工程名称
6. 查询供应商S1提供的零件的颜色
7. 查询为工程J1或J2提供零件的供应商代号
8. 查询为工程J1提供红色零件的供应商代号
1.select * from j where city='上海'
2.select * from p where weight=(select min(weight) from p)
3.select sno from spj where jno='J1'
4.select sno from spj where jno='J1' and pno='P1'
5.select JNO from spj where sno='S1'
6.select t2.color from spj t1 left outer join p t2 on t1.pno=t2.pno where p1.sno='S1'
7.select sno from spj where jno='J1' or jno='J2'
8.select t1.sno from spj t1 left outer join p t2 on t1.pno=t2.pno where p2.color='红'
又帮做作业。。。
1.SELECt * FROM J WHERe CITY='上海';
2.SELECt PNO FROM P WHERe WEIGHT IN (SELECt MIN(WEIGHT) FROM P);
3.SELECt SNO FROM SPJ WHERe JNO='J1';
4.SELECt SNO FROM SPJ WHERe JNO='J1' AND PNO='P1';
5.SELECt JANME FROM SPJ ,J WHERe SNO=S1 AND SPJ.JNO=J.JNO;
6.SELECt COLOR FROM SPJ ,P WHERe SNO=S1 AND SPJ.PNO=P.PNO;
7.SELECt SNO FROM SPJ WHERe JNO IN ('J1','J2');
8.SELECt SNO FROM SPJ WHERe JNO='J1' AND PNO IN (SELECT PNO FORM P WHERe COLOR='红色');
1 select * from J where CITY='上海'
2 select PNO,MIN(WEIGHT) from P group by PNO
3 select SNO from SPJ where JNO='J1'
4 select SNO from SPJ where JNO='J1' and PNO='P1'
5 select b.JNAME from SPJ a, J b where a,JNO=b.JNO and a.SNO='S1'
6 select a.COLOR from P a, SPJ b where a.JNO=b.JNO and b.SNO='S1'
7 select SNO from SPJ where JNO='J1' or JNO='J2'
8 select SNO from SPJ a,P b where a.PNO=b.PNO and b.COLOR='红色'