数据库系统原理与实践 陈红顺 实验五 数据查询

版权声明:转载注明康弘雲 https://blog.csdn.net/weixin_43560803/article/details/83547297


 

第三题
/*(1)*/

select userId,userName,userState
from userInfo,book
where bookID = '1001'

2
select userName,sex,orderTime
from userInfo,orderInfo,orderBook
where orderBook.bookID = '1001' and orderInfo.orderID = orderBook.orderID and orderState = '已完成' and orderInfo.userID = userInfo.userID
order by orderTime desc

3
select Distinct userinfo.userId,userName,sex,userState
from userInfo,book,orderBook,orderinfo
where userInfo.sex = '1' and book.categoryID = '2' and orderInfo.orderState = '已完成' and orderInfo.userID = userinfo.userid

4
select title ,price,press,quantity
from orderBook,book
where orderBook.bookID=book.bookID and price>=37 and quantity>=2 order by quantity desc

5
select Distinct orderinfo.orderID,ordertime,userstate
from orderBook,userInfo,orderInfo
where orderinfo.userID=102

6
select  orderinfo.orderID,username,title,category.categoryid,quantity
from orderinfo,orderbook,userInfo,book,category
WHERE orderState = '已支付' and orderInfo.userID = userInfo.userID and orderBook.bookID = orderInfo.orderID and book.categoryID = category.categoryID
order by orderID

四
1




2
select distinct orderinfo.orderID,ordertime,username,orderstate
from orderBook,orderInfo,userInfo
where orderBook.bookID in
(select bookID from orderBook where orderBook.orderID = '2016003')
and orderInfo.userID = userInfo.userID



3
select distinct userInfo.*
from userInfo,orderInfo
where orderInfo.orderID in
(select orderID from book,orderBook where press = '清华大学出版社' and book.bookID = orderBook.bookID)
and orderInfo.userID = userInfo.userID


4
select*
from userInfo
where userID in
(select userID from orderInfo where orderID in (select orderID from orderBook where bookID in(select bookID from userInfo,orderInfo,orderBook where userInfo.userName = '王丽' and userInfo.userID = orderInfo.userID and orderBook.orderID = orderInfo.orderID)));


5



6
select userInfo.*
from userInfo
where userID in
(select userid from orderInfo where orderID in
(select orderID from orderBook where bookID in
(select bookID from orderBook where orderID in
(select orderID from orderInfo where userID in
(select userID from userInfo where username = '张三')))));


五
1
select distinct userid,username,userstate
from userInfo,category,book
where (sex=1 and category.categoryName = '人文社科类')


2
select  userInfo.userID,username,userstate
from userInfo,category,book,orderInfo
where category.categoryName = '人文社科' and category.categoryID = book.categoryID
group by orderInfo.userID
having COUNT(*)>=1


实验六
第一题
1

猜你喜欢

转载自blog.csdn.net/weixin_43560803/article/details/83547297
今日推荐