A. 请用sql语句完成以下操作:查询book表中书名为’计算机基础’的图书编号、作者。 要怎么写
select book_id, author from book where book_name ='计算机基础'
能看懂么
B. 怎么在sql查询语句中查一类书中具体查一本书的价格,出版社
select 价格,出版社
from 图书列表
where 书名='要查的书名'
and 类别=‘要查的书的类别 ’
C. mysql在[图书明细]表中查询"书名"中含有"入门"字眼的图书信息,显示所有列。
摘要 1、首先在mysql数据库,创建一张data表,表内插入多条数据,用于测试。
D. 数据库SQL语句实现下列问题
create proc t1
@dzno int,
@num int output
as
select @num=count(书号) from 借阅 where 读者号=@dzno
return @num
go
create proc t2
@bookname varchar(50),
@author varchar(20)
as
select 出版社,单价 from 图书 a where 书名 =@bookname and 作者=@author
go
create proc t3
@readername varchar(10),
@bookno int
as
declare @num int,@readerno int
select @readerno=读者号 from 读者 where 姓名=@readername
exec t1 @readerno,@num output
if @num>=(select 允许借阅册数 from 读者类别 a, 读者 b where a.姓名=@readername and a.读者类别编号=b.读者类别编号)
begin
print '超出允许借阅册数,不能再借了'
return
end
declare @days int
select @days=允许借阅天数 from 读者类别 a, 读者 b where a.姓名=@readername and a.读者类别编号=b.读者类别编号
print '借阅成功!'
insert into 借阅 values( @readerno,@bookno,getdate(),dateadd(dd,@days,getdate())
E. sql语句查询(图书借阅)
1,查询所有借过书的学生编号,姓名,专业,?SELECT DISTINCT borrow.stuid, student.major
FROM borrow LEFT OUTER JOIN
student ON borrow.stuid = student.stuID2,借书但是未归还的学生姓名及该生未归还书的图书数量?SELECT student.stuName, COUNT(1) AS Expr1
FROM borrow LEFT OUTER JOIN
student ON student.stuID = borrow.stuid
WHERE (borrow.b_time IS NULL)
GROUP BY student.stuName3,比如书名是《天龙八部》,请分别查询借过它的人的姓名,借书日期,看了多少天,要考虑若某人借了但是没还,则在看了多久一栏填上(尚未归还)SELECT student.stuName, borrow.t_time, CASE WHEN borrow.b_time IS NULL THEN '尚未归还' ELSE cast(datediff(day,t_time,b_time) as varchar) END AS Expr1
FROM borrow LEFT OUTER JOIN
student ON student.stuID = borrow.stuid LEFT OUTER JOIN
book ON borrow.bid = book.Bid
WHERE (book.title = '天龙八部')
F. sql中三个关系,学生、书籍和借,查询借了某出版社出版的所有书的学生姓名,如何写sql语句
---借了所有书籍的学生的学生姓名
select sname from student
where not exists(
select * from book
where not exists(
select * from stu_book
where sno=student.sno
and isbn=book.isbn
)
)
--借了某出版社出版的所有书的学生姓名
select sname from student
where not exists(
select * from book
where cbs='xxx出版社' and not exists(
select * from stu_book
where sno=student.sno
and isbn=book.isbn
)
)
G. SQL语句完成以下操作: 1、查询所有书名包括“数据库”的图书记录
select * from 表名 where 列名 like '%数据库%'
H. 在SQL语句中要查询book表中所有书名中以 计算机 开头的书籍的价格,可用什么语句
SELECT book.书名, book.价格
FROM book
WHERE (((book.书名) Like "计算机*"));
I. SQL 图书管理系统的查询语句
1. 求总藏书量、藏书总金额,总库存册数、最高价、最低价。
select count(图书编号) as 总藏书量,
sum(定价) as 藏书总金额,
sum(实际数量) as 总库存册数,
max(定价) as 最高价,
min(定价) as 最低价
from 图书卡片
go
2. 列出藏书在10本以上的书(书名、作者、出版社、年份)。
select 图书名称,作者姓名,出版社,出版日期
from 图书卡片
group by 图书编号 having(coung(1)>10)
order by 图书名称
go
3. 哪些出版社的藏书种类数超过100种。
select 出版社 as '藏书种类数超过100种的出版社'
from 图书卡片
group by 出版社 having(count(类别)>100)
order by 出版社
go
4. 目前实际已借出多少册书?
select sum(借出数量) as '借出数量'
from 图书卡片
go
5. 年份最久远的书。
select top 1 with ties 图书名称 from 图书卡片
order by 出版日期
go
6. “数据库系统原理教程,王珊编,清华大学出版社,1998年出版”还有几本?
select count(1) from 图书卡片
where concaints(摘要,'"数据库系统原理教程,王珊编,清华大学出版社,1998年出版"')
go
7. 哪一年的图书最多?
select top 1 with ties convert(substring(出版日期,1,4)) as 年份,count(1) as '图书数量'
from 图书卡片
group by 出版日期
order by 图书数量 desc
go
8. 哪本借书证未归还的图书最多?
select top 1 with ties A.读者编号,count(1) as '借书数量'
from 图书卡片 A,借阅 B
where A.图书编号=B.图书编号
group by A.读者编号
order by 借书数量 desc
go
9、平均每本借书证的借书册数。
select avg(借阅数量) as '平均每本借书证的借书册数'
from 借阅
go
10.哪个系的同学平均借书册数最多?
select top 1 with ties A.工作单位,avg(借阅数量) as '平均借阅数量'
from 读者 A,借阅 B
where A.读者编号=B.读者编号
group by A.工作单位
order by 平均借阅数量' desc
go
11. 最近两年都未被借过的书。
select 图书名称
from 图书卡片
where 图书编号 in(select 图书编号 from 借阅 where datediff(year,借阅日期,getdate())>2)
go
12. 列出那些借了图书逾期未归还的借书证号和图书名。
select A.读者编号 as '借书证号',B.图书名称
from 读者 as A inner join 图书卡片 as B on A.图书编号=B.图书编号
where A.应归还日期<getdate() and A.实际归还日期 is null
go
13.今年未借过书的借书证。
select 读者编号
from 读者
where 读者编号 not in(select 读者编号
from 读者
where datediff(year,借阅日期,getdate())=0)
go
14. 今年那种书出借最多?
select top 1 with ties A.类别,count(1) as '借出数量'
from 图书卡片 A,借阅 B
where datediff(year,B.借阅日期,getdate())=0
group by A.类别
order by 借出数量' desc
go
J. 数据库检索SQL语句题目求 解答
1、select 图书编号,书名,定价 from 图书 where 出版社标号='CS';
2、select 图书.书名,图书.定价,出版社.出版社名称 from 图书,出版社 where 图书分类='教材' and 图书.出版社编号=出版社.出版社编号;
3、select 出版社编号,count(图书编号),avg(定价) from 图书 group by 出版社编号;
4、select 图书.图书编号,图书.书名 from 图书,出版社 where 图书分类='教材' and 图书.出版社编号=出版社.出版社编号 and 出版社.出版社编号=‘高等教育出版社’ and 图书.定价>30;