现有图书借阅关系数据库如下: 图书(图书号,书名,作者,单价,库存量) 读者(读者号,姓名,工作单位,地址) 借阅(图书号,读者号,借期,还期,备注)其中,还期为NULL表示该书未还。 用SQL语言实现下列查询: 1)检索读者号为R6的读者姓名、工作单位。 2)检索借阅图书号为B6的读者姓名。 3)检索读者“李红”所借图书的书名。 4)检索读者号为R1的读者所借图书中未还的书名。 5)检索书名为“操作系统”的图书的最高单价和最低单价。 6)检索单价在20到30元(包含20和30)之间的图书的书名及库存量。 7)检索所有姓王的读者所借图书的图书号、借期和还期。 8)检索与“张三”同一工作单位的读者号和读者姓名。 9)将读者“李红”所借图书的信息从借阅表中删除。 10)将读者号为R2的读者所借图书的还期增加10天。
1)select 姓名,工作单位 from 读者where 读者号=’R6’ 2)select 姓名 from 读者 a,借阅 b where a.读者号=b.读者号 and 图书号=’B6’ 3)select 书名 from 图书 a,读者 b,借阅 c where a.图书号=c.图书号 and b.读者号=c.读者号 and 姓名=’李红’ 4)select 书名 from 图书 a,借阅 b where a.图书号=b.图书号 and 读者号=’R1’ and 还期 is null 5)select max(单价),min(单价) from 图书 where 书名=’操作系统’ 6)select 书名,库存量 from 图书 where 单价between 20 and 30 7)select 图书号,借期,还期 from 借阅 where 读者号 in (select 读者号from 读者 where 姓名like ’王%) 8)select 读者号,姓名 from 读者where 工作单位=(select 工作单位 from 读者where 姓名=’张三’) 9)delete from 借阅 where 读者号 in (select 读者号 from 读者where 姓名=’李红’) 10)update 借阅 set 还期=还期+10 where 读者号=’R2’