数据库由这4个表儿,想查出“取出上海供应商不提供任何零件的工程代号” 黑笔是我自己写的,红笔是正确

数据库由这4个表儿,想查出“取出上海供应商不提供任何零件的工程代号” 黑笔是我自己写的,红笔是正确,第1张

你要先搞清楚你要查内容的逻辑结构,看你自己写的语句翻译之后,只能查出来上海供应商参与的工程编号,实际上我觉得红字的查血语句还可以在简化,没必要再去J表里查询,直接查供应关系表里不与上海供应商合作的项目编号就可以

select distinct jn from spj where sn != (select sn from s where city="上海");

(1) select SNO '供应商号' from SPJ where JNO = 'J1'

(2) select JJNAME from

SPJ inner join P on SPJSNO = PPNO inner join J on SPJJNO = JJNO

where JCITY = '上海' and PCOLOR = '红色'

(3) select PPNAME,COUNT(SPJQTY) from

SPJ inner join P on SPJSNO = PPNO inner join J on SPJJNO = JJNO

where JJNO = 'J2'

group by PPNAME

(4) select JJNO from

SPJ inner join P on SPJSNO = PPNO and PCOLOR = '红色' inner join J on SPJJNO = JJNO inner join S on SPJSNO = SSNO

where SCITY <> '天津'

(5) select PPNO,COUNT(SPJQTY) 'count' from

SPJ inner join P on SPJSNO = PPNO inner join J on SPJJNO = JJNO

group by PPNO

order by count desc

(6) update P set PCOLOR ='蓝色' where Color = '红色'

(7)

create view view_s

as

select from

SPJ inner join P on SPJSNO = PPNO inner join J on SPJJNO = JJNO inner join S on SPJSNO = SSNO

where SSNO = 'S1'

(8) delete from SPJ where JNO ='J1'

不知对不对,仅供参考~

1select sno from spj where sno=j1;

2select sno from spj where sno=j1 and pno = p1;

3select sno from spj where sno = j1 and pno in ( select pno from p where color = red)

4select jno from spj where sno not in ( select sno from s where city = tianjin)

And pno not in ( select pno from p where color = red)

5select sname city from s

6select PNAME,COLOR,WEIGHT from p;

7select jno from spj where sno = s1;

8 select pname ,qty from spj as a ,p as b where apno = bpno and jno = j2

9 select pno from s , spj where sno = spjsno and city = shanghai;

10 select jno from s , spj where sno = spjsno and city = shanghai

11select jno from s , spj where sno = spjsno and city ! = tianjin

①找到供给工程项目J1的任何一种零件的最大供应量

SELECT MAX(QTY)

FROM SPJ

WHERE JNO='J1'

②找到使用零件P1的工程

SELECT DISTINCT JNO

FROM SPJ

WHERE PNO='P1'

③因为需要按工程统计零件平均数 对上一步从SPJ选出的记录按JNO分组 并且分组结果满足①

GROUPBY JNO

HAVING

以上就是关于数据库由这4个表儿,想查出“取出上海供应商不提供任何零件的工程代号” 黑笔是我自己写的,红笔是正确全部的内容,包括:数据库由这4个表儿,想查出“取出上海供应商不提供任何零件的工程代号” 黑笔是我自己写的,红笔是正确、数据库问题、数据库上机考试、跪求大神 跪求答案、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10146439.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存