1、 查和“S0701026”
读者借了相同
图书的读者的图书证号和
姓名 select rno,rn from reader where rno in(select a.rno from borrow as a,borrow as b where a.bno=b.bno and b.rno='S0701026') 2、 查询每个读者的姓名和所借图书名 select rn,bn from reader,borrow,book where reader.rno=borrow.rno and borrow.bno=book.bno 3、 查没有借书的读者的图书证号和姓名 select rno,rn from reader where rno not in(select rno from borrow) 4、 查询借阅了“数据结构”的读者数量 select count(*) from borrow where bno=(select bno from book where bn='数据结构') group by bno 5、 查“李丽”和“张朝阳”都借阅了的图书的书号 select a.bno from borrow as a,borrow as b where a.rno=(select rno from reader where rn='李丽') and b.rno=(select rno from reader where rn='张朝阳') and a.bno=b.bno 6、 查询借书上限最大的读者信息 select * from reader where rup=(select max(rup) from reader) order by rup desc 7、 查询借阅图书数量达到2本的读者信息 select * from reader where rno in(select rno from borrow group by rno having count(*)>1) 8、 查询每个读者姓名,所借图书的图书号,没有借书的读者也列出来 select reader.rn,bno from reader left join borrow on reader.rno=borrow.rno 9、 查询没有借阅“C程序设计”的读者姓名 select rn from reader where rno not in(select rno from borrow where bno=(select bno from book where bn='C程序设计')) 10、 检索所有姓李的读者所借图书的书号 select bno from borrow where rno in(select rno from reader where rn like '李%') 11、 查被借出的图书编号以“TP”开头的图书信息 select * from book where bno in(select bno from borrow where bno like 'TP%') 12、 查没有被借阅的图书信息 select * from book where bno not in(select bno from borrow) 13、 查询借阅了“数据库原理及其应用教程”的读者的图书证号和姓名 select reader.rno,rn from reader,borrow,book where reader.rno=borrow.rno and borrow.bno=book.bno and bn='数据库原理及其应用教程' 14、 统计各个系读者的数量,显示系名和数量 select rde 系名,count(*) 数量 from reader group by rde 15、 查询有过期未还图书的读者的书号、姓名、所在系 select bno,rn,rde from reader,borrow where reader.rno=borrow.rno and rda <getdate() 16、 检索至少借阅了“数据结构”和“ *** 作系统教程”的读者图书证号 select a.rno from borrow as a,borrow as b where a.bno=(select bno from book where bn='数据结构') and b.bno=(select bno from book where bn=' *** 作系统教程') and a.rno=b.rno 17、 查库存书的总数 select sum(bnu) from book 18、 查询借阅了图书的读者信息 select * from reader where rno in(select rno from borrow)1
select s.sno,s.sname from s,c,sc where s.sno=sc.sno and c.cno=sc.cno and c.cname='MS'
2
select sno from sc where cno='C1' and sno in (select sno from sc where cno='C3')
3
select s.sno,sc.grade from s,c,sc where s.sno=sc.sno and c.cno=sc.cno and c.cname in('数据库',' *** 作系统')
4
select sno,sname,age from s where 性别='女' and age between 18 and 20
5
select s.sno,s.sname,sc.grade from s,c,sc where s.sno=sc.sno and c.cno=sc.cno and c.teacher='刘平'
6
select distinct s.sname from s,sc where s.sno=sc.sno and cno in(select cno from sc having count(distinct cno)=(select count(*) from c))
7
select distinct sname from s where sno in(select sno from sc where cno in(select cno from sc where sno='1042') group by sno having count(*)=(select count(*) from sc where sno='1042'))
8
select sname,age,所在系 from s where sname like '樊%'
9
select sname,age,所在系 from s where sno in(select sno from sc group by sno having count(*)>3)
其中4,8,9,你给的字段里分辨不出来哪些字段是性别和所在系,根据实际情况自己替换
评论列表(0条)