基础题,求牛人帮助
1.输入SQL语句,实现查询借过“软件工程”和“操作系统”两本书的所有读者的信息
select rno,rname from borrow(消息 209,级别 16,状态 1,第 1 行
列名 'rno' 不明确。)
inner join reader on borrow.rno=reader.rno
inner join book on borrow.bno=book.bno
where bname='软件工程' and bname='操作系统'
2.输入SQL语句,实现删除“数据结构”的所有借书记录
delete borrowno,bno,rno,pubdate from borrow (消息 102,级别 15,状态 1,第 1 行
',' 附近有语法错误。)
inner join book on borrow.bno=book.bno
where bname='数据结构'
3.输入T-SQL语句,利用游标循环遍历图书表的每条记录,然后关闭并释放游标
declare mycursor cursor for select * from book
open mycursor
fetch @@fetch_status=0 (提示这行有问题)
begin
fetch next from mycursor
end
close mycursor
deallocate mycursor------解决方案--------------------1.
select borrow.rno,borrow.rname from borrow
inner join reader on borrow.rno=reader.rno
inner join book on borrow.bno=book.bno
where bname='软件工程' and bname='操作系统'
2.
delete from borrow
inner join book on borrow.bno=book.bno
where bname='数据结构'
3
OPEN authors_cursor
declare mycursor cursor for select * from book
open mycursor
WHILE @@FETCH_STATUS = 0
begin
fetch next from mycursor
end
close mycursor
deallocate mycursor
------解决方案--------------------SELECT book.bname ,
book.author ,
book.publish
FROM borrow
INNER JOIN reader ON borrow.rno = reader.rno
INNER JOIN book ON borrow.bno = book.bno
WHERE reader.rname = '李莎'