一、BETWEEN操作符的基本用法

BETWEEN操作符用于选取两个值范围内的值。

语法格式如下:

SELECT 列名1,列名2... FROM 表名 WHERE 列名 BETWEEN 值1 AND 值2;

示例student表:

例子:

SELECT * FROM student WHERE student_number BETWEEN 20190100 AND 20190200;

运行结果:

当然也可以使用NOT关键字,查找不在两个值范围内的数据:

SELECT * FROM student WHERE student_number NOT BETWEEN 20190100 AND 20190200;

运行结果: