资源描述:
《P127第3章SQL练习答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第2章第5题(1)SelectSNOFromSPJWhereJNO=’J1’(2)SelectSNOFromSPJWhereJNO=’J1’AndPNO=’P1’(3)SelectSNOFromSPJ,PWhereSPJ.PNO=P.PNOAndJNO=’J1’AndColor=’红’(4)selectdistinctjnofromspjWhereJNOnotin(selectdistinctjnofromspj,s,pwherespj.sno=s.snoandp.pno=spj.pnoandcity='天津'a
2、ndcolor='红')(5)selectdistinctjnofromspjspjxwherenotexists(select*fromspjspjywherespjy.sno='S1'andnotexists(select*fromspjspjzwherespjz.jno=spjx.jnoandspjz.pno=spjy.pno))第3章第5题(1)SelectSname,CityFromS(2)SelectPname,Color,WeightFromP(3)SelectDistinctJNOFromSPJW
3、hereSNO='S1'(1)SelectPNAME,QTYFromSPJ,PWhereSPJ.PNO=P.PNOAndJNO='J2'(2)SelectDistinctPNOFromSPJ,SWhereSPJ.SNO=S.SNOAndCity='上海'(3)SelectDistinctJnameFromSpj,J,SWhereSPJ.JNO=J.JNOAndSPJ.SNO=S.SNOAndS.City='上海'(4)SelectDistinctJnoFromSpjWhereJnoNotIn(SelectDist
4、inctJnoFromSpj,SWhereSpj.Sno=S.SnoAndCity='天津')(5)UpdatePSetColor=’蓝’WhereColor='红'(6)UpdateSpjSetSno='S3'WhereSno='S5'AndJno='J4'AndPno='P6'(7)DeleteFromSPJWhereSNO='S2'DeleteFromSWhereSNO='S2'(8)InsertintoSPJValues('S2','J6','P4',200)图书管理关系数据模型练习题答案:(1)Sele
5、ct单位From读者Where姓名=’张平’(2)Select书名,作者From图书Where出版单位=‘人民出版社’or出版单位=‘科学出版社’(1)Select书名From图书Where单价Between10And15OrderBy单价Desc(2)Select姓名,借阅日期From读者,借阅Where借阅.借书证号=读者.借书证号(3)Select图书.*From图书,借阅Where图书.总编号=借阅.总编号and单价>20OrderBy单价Desc(4)Select图书.*From图书Where出版单位=
6、(Select出版单位From图书Where书名=’数据库原理’)(5)SelectCount(*)From读者Where单位=’计算机科学系’GroupBy单位(6)SelectMax(单价),Min(单价),Avg(单价)From图书GroupBy出版单位(7)Select姓名,单位From读者Where借书证号NotIn(SelectDistinct借书证号From借阅)(8)Select姓名,单位From图书,读者,借阅Where图书.总编号=借阅.总编号And借阅.借书证号=读者.借书证号And书名=’
7、数据结构’(1)Select姓名,单位From读者,借阅Where读者.借书证号=借阅.借书证号GroupBy借阅.借书证号HavingCount(*)>=5(2)Select书名,作者From图书Where书名Like‘数据库%’(3)Select书名From图书Where单价>All(Select单价From图书Where出版单位=’高等教育出版社’)