第1关:null值的判断
任务描述
本关任务:如何判断null值
相关知识
为了完成本关任务,你需要掌握: null值
null
在mysql中,null表示空值 判断某个表达式是否null值,不能通过=运算符 通过<表达式><=>null或者<表达式>is null 可以判断某个表达式是否为null。如果<表达式>为null,返回1,否则返回0.
任务要求
第一题 查询借阅(borrow)数据表中没有归还的记录的所有字段的值。 当还书日期(hsrq)为null值,表示图书尚未归还。
开始你的任务吧,祝你成功!
use library;
#代码开始
select *
from borrow
where hsrq is null;
#代码结束
第2关:between and和in运算
use library
#代码开始
#答案一
select txm,sm,sj from book
where sj between 10 and 20 ;
#答案二
select txm,sm,cbs from book
where cbs not in ("上海古籍出版社","中华书局");
#代码结束
第3关:like运算符
use library;
#代码开始
#答案1
select txm,sm from book where sm like "%诗%";
#答案2
select txm,sm from book where sm like "诗%";
#代码结束
第4关:逻辑运算符
use library;
#代码开始
#答案1
select * from reader where xb="男" and sf="研究生";
#答案2
select * from reader where xb="男" and sf="研究生" or sf="工作人员" and xb="男";
#代码结束