针对供应管理数据库SPJ,进行各种嵌套与集合查询供应管理数据库SPJ模式: 供应商表S(SNO,SNAME,STAT,CITY) 零部件表P(PNO,PNAME,COLOR,WT) 工程项目表J(JNO,JNAME,CITY) 供应情况表SPJ(SNO,PNO,JNO,QTY):(10)查询给“长春一汽”项目供应“螺母”零件最多的供应商信息和供应情况; (11)查询使用了“螺母”或“螺丝刀”零件的工程项目信息; (12)查询既使用了“螺母”又使用了“螺丝刀”零件的工程项目信息; (13)查询使用了“螺母”零件但没有使用“螺丝刀”零件的工程项目信息; (14)查询使用过所有供应商供应的零件的工程项目信息。
时间: 2024-02-19 16:02:00 浏览: 378
(10) SELECT TOP 1 S.SNO, S.SNAME, S.STAT, S.CITY, SPJ.QTY FROM S, SPJ WHERE S.SNO = SPJ.SNO AND SPJ.JNO = (SELECT JNO FROM J WHERE JNAME = '长春一汽') AND SPJ.PNO = (SELECT PNO FROM P WHERE PNAME = '螺母') ORDER BY SPJ.QTY DESC;
(11) SELECT DISTINCT J.JNO, J.JNAME, J.CITY FROM J, SPJ WHERE J.JNO = SPJ.JNO AND SPJ.PNO IN (SELECT PNO FROM P WHERE PNAME IN ('螺母', '螺丝刀'));
(12) SELECT DISTINCT J.JNO, J.JNAME, J.CITY FROM J, SPJ AS S1, SPJ AS S2 WHERE J.JNO = S1.JNO AND S1.JNO = S2.JNO AND S1.PNO = '螺母' AND S2.PNO = '螺丝刀';
(13) SELECT DISTINCT J.JNO, J.JNAME, J.CITY FROM J, SPJ AS S1 WHERE J.JNO = S1.JNO AND S1.PNO = '螺母' AND J.JNO NOT IN (SELECT JNO FROM SPJ WHERE PNO = '螺丝刀');
(14) SELECT J.JNO, J.JNAME, J.CITY FROM J WHERE NOT EXISTS (SELECT S.SNO FROM S WHERE NOT EXISTS (SELECT P.PNO FROM P WHERE P.PNO = SPJ.PNO AND SPJ.SNO = S.SNO AND SPJ.JNO = J.JNO));
阅读全文