文章利用了几个实例来介绍关于sql between 条件语句的用法,有需要的朋友可以参考一下这个函数。
between 条件,允许您检索在一定范围内的值。
between的语法是:
代码如下 复制代码
select columns
from tables
where column1 between value1 and value2;
实例
代码如下 复制代码
select *
from suppliers
where supplier_id between 5000 and 5010;
当也可以用其它来判断
代码如下 复制代码
select *
from suppliers
where supplier_id >= 5000
and supplier_id
对日期的操作
实例,求两日期之间的数据
代码如下 复制代码
select *
from orders
where order_date between to_date ('2003/01/01', 'yyyy/mm/dd')
and to_date ('2003/12/31', 'yyyy/mm/dd');
另一种方法
代码如下 复制代码
select *
from orders
where order_date >= to_date('2003/01/01', 'yyyy/mm/dd')
and order_date
实例三 not between
代码如下 复制代码
select *
from suppliers
where supplier_id not between 5000 and 5500;
另一种方法
代码如下 复制代码
select *
from suppliers
where supplier_id or supplier_id > 5500;