轻松上手,快乐学习!

SQL BETWEEN 关键字


BETWEEN

BETWEEN命令用于选择给定范围内的值。值可以是数字,文本或日期。 BETWEEN命令是包括开始值和结束值。 以下SQL语句选择BETWEEN 10和20之间的所有产品:

实例

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
运行实例»
要显示上一示例范围之外的产品,请使用NOT BETWEEN:

实例

SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
运行实例»
以下SQL语句选择等于'ProductName BETWEEN'Carnarvon Tigers'和'Mozzarella di Giovanni'的产品:

实例

SELECT * FROM Products
WHERE ProductName BETWEEN 'Carnarvon Tigers' AND 'Mozzarella di Giovanni'
ORDER BY ProductName;
运行实例»