1.内联接查询在管理学院资料室的数据库类书的信息
selectdbo.BookInfo.*,dbo.Books.* fromdbo.BookInfo,dbo.Books
wheredbo.BookInfo.ISBN=dbo.Books.ISBNand位置='管理学院资料室'
2.左外联接查询分类为3的用户的姓名、单位、及借阅情况。
selectdbo.Users.姓名,dbo.Users.单位,dbo.Loan.借阅日期,dbo.Loan.书号,Loan.借阅证号
fromdbo.Usersleftouterjoindbo.Loanon(dbo.Loan.借阅证号=dbo.Users.借阅证号) wheredbo.Users.分类='3'
3.使用子查询查询与借阅证号为“J00016”的用户在同一单位的所有用户的借阅证号
和姓名。
select借阅证号,姓名 fromdbo.Users
where单位in(select单位 fromdbo.Users
where借阅证号='J00016')
4.使用子查询查询所有借书预约成功的用户的姓名和E_mail,以便通知他们。
SELECTdbo.Users.姓名,dbo.Users.E_mail fromdbo.Users
wheredbo.Users.借阅证号in(select借阅证号 fromdbo.Reservation where状态='T')
5.使用子查询查询类别为“.教师”的用户的借书情况。
selectdbo.Loan.* fromdbo.Loan
where借阅证号in(select借阅证号 fromdbo.Users where分类='3')
6.计算相关子查询查询借阅数量大于3本的用户的借阅证号、姓名、单位。
selectdbo.Users.借阅证号,dbo.Users.姓名,dbo.Users.单位 fromdbo.Users
where借阅证号=(select借阅证号 fromdbo.LoanHist groupby借阅证号 havingCOUNT(借阅证号)>3 )
7.查询所有曾经借过书号为“A0450049”这本书的所有用户的借阅证号和姓名。