用于范围比较的关键字有俩个:between和in
between:在俩者之间
--查询表中出生时间在1995年到1996年末的学生信息:
select * from xsb
where 出生时间 between '1995-1-1' and '1996-12-31';
--查询表中出生时间不在1995年到1996年的学生信息:
select * from xsb
where not 出生时间 between '1995-1-1' and '1995-12-31';
--效果相同
select * from xsb
where 出生时间 not between '1995-1-1' and '1995-12-31';
in:在…内
select * from xsb
where 总学分 in (12,23,42,50);
--即使 IN 中的数据,表中并不存在也不会报错
select * from xsb
where NOT 总学分 in (12,23,42,50);
--效果相同
select * from xsb
where 总学分 not in (12,23,42,50);