2019-11-29_between

between: 按规定返回所需记录的数目

格式如下:

 列名     包含与 “A” and “B”

select * from table where “列名” between “A” and “B”(包含A,B)

列名     不包含与 “A” or “B”

select * from table where “列名” not between “A” and  “B”(不包含A,B)

例如:表如下

(插入表的语句参照文章2019-11-22)


1.需求:按age(年龄)排序,查询出前年龄介于12岁到13岁之间的学生

select * from student WHERE age BETWEEN 12 and 13

等价于    select * from student WHERE age >= 12 and  age <= 13

结果如下:


2.需求:按age(年龄)排序,查询出前年龄小于11或者大于12岁的学生

select * from student WHERE age not BETWEEN 11 and 12

等价于    select * from student WHERE age < 11 or  age > 12


你可能感兴趣的:(2019-11-29_between)