资源描述:
《数据库图书查询》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、三个表:图书信息表、读者信息表、借阅表图书信息(书号、书名、作者、出版日期、出版社、图书存放位置、总数量)读者信息表(图书证号、姓名、所在系、借书上限数)借阅表(图书证号、书号、借出日期、应还日期)数据库表结构如下:BOOK(BNO,BN,BAU,BDA,BPU,BPL,BNU)READER(RNO,RN,RDE,RUP)BORROW(RNO,BNO,BDA,RDA)1.查询被借阅的图书号以’TP’开头的图书信息select*frombookwherebnoin(selectbnofromborrowwherebnolike'TP%')2.查和“S
2、0701026”读者借了相同图书的读者的图书证号和姓名Selectrno,rnfromreaderWherernoin(selectrnofromborrowWherebnoin(selectbnofromborrowWhererno=’S0701026’))3.检索至少借阅了“数据结构”和“操作系统教程”的读者图书证号selectborrow.rnofromborrow,bookwhereborrow.bno=book.bnoandbn='数据结构'andrnoin(selectborrow.rnofromborrow,bookwhereborr
3、ow.bno=book.bnoandbn='操作系统教程')4.查询没有借阅“C程序设计”的读者姓名selectrnfromreaderwherernonotin(selectrnofromborrowwherebno=(selectbnofrombookwherebn='C程序设计'))5.查询张朝阳和李丽都借阅的图书书号selectA.bnofromborrowasA,borrowasBwhereA.rnoin(selectrnofromreaderwherern='李丽')andB.rnoin(selectrnofromreaderwhere
4、rn='张朝阳')andA.bno=B.bno6.查询借阅了图书的读者信息Select*FromreaderWherernoin(Selectrnofromborrow)7.查没有被借阅的图书信息select*frombookwherebnonotin(selectbnofromborrow)8.查没有借书的读者的图书证号和姓名selectrno,rnfromreaderwherernonotin(selectrnofromborrow)9.查询借阅图书数量达到2本的读者信息select*fromreaderwherernoin(selectrno
5、fromborrowgroupbyrnohavingcount(bno)>=2)10.查询有过期未还图书的读者的书号、姓名、所在系selectborrow.bno,reader.rn,reader.rdefromborrow,readerwhereborrow.rda6、,tel,sex)SC(sno,cno,grade)C(cno,cname,teacher,pcno)完成下列查询任务:1、检索至少选修课程“数据结构”和“C语言”的学生学号。Selectx.snoFromSCASx,SCAsyWherex.sno=y.snoandx.cno=(SelectcnoFromCWherecname='数据结构')andy.cno=(SelectcnoFromCWherecname='C语言')2、检索学习课程号为C02的学生学号和姓名。SelectS.sno,snameFromS,SCWhereSC.sno=S.sno
7、andSC.cno='C02'3、检索选修课程“数据库”的学生学号和姓名。SelectS.sno,snameFromS,SC,CWhereSC.sno=S.snoandSC.cno=C.cnoandC.cname='数据库'4、检索选修课程号为C02或C04的学生学号。SelectdistinctS.snoFromS,SCWhereSC.sno=S.snoand(SC.cno='C02'orSC.cno='C04')5、检索至少选修课程号为C02和C04的学生姓名。SelectsnameFromSWheresnoin(Selectx.snoFrom
8、SCASx,SCAsyWherex.sno=y.snoandx.cno='C02'andy.cno='C04')6、检索没