1. 查询所有的读者信息,包括年龄
select reader.*,year(now())-year(birthday)
from reader
2. 添加一条借阅记录,01002号读者借阅0003号图书,借阅日期为今天
use readbook;
insert into borrow
values('01002','0003',curdate(),null)
3. 查询计信专业的读者信息
select reader.*
from reader
where mid(unit,1,2)='计信'
4. 查询所有图书信息,价格在30以下的显示便宜,30以上的显示贵
select book.*,if(price<30,'便宜','贵')
from book
5. 查询所有的借阅信息,没还书的显示“没还”,否则显示“已还”
select borrow.*,if(returndate is null,'没还','已还')
from borrow
6. 查询所有2个月前借的还没还的借书信息
select *
from borrow
where borrowdate>date_sub(now( ), interval 2 month) and
returndate is null;
7. 查询年龄大于19的读者信息
select reader.*
from reader
where year(now())-year(birthday)>19
8. 修改图书的价格,30以下的图书价格提高20%,30以上的图书价格提高10%
update book
set price=if(price<30,price* 1.2,price* 1.1)