English | 正體中文 | 简体中文

SQL between


范例资料表 : Orders (以下范例皆用此表当作资料来源)
OrderNo CustomerName SalePrice Quantity OrderDate
20101213095 John 3500 10 2010-12-13
20100620135 Jimmy 2509 22 2010-06-20
20100620392 Vincent 7200 5 2010-06-20
20100530006 Tyler 9200 50 2010-05-30
20100515029 Alan 100 50 2010-05-29


Example
选择在两个日期之间的资料

Sytax : SELECT * FROM table_name WHERE column_name BETWEEN date1 AND date2
SQL
SELECT * FROM Orders WHERE OrderDate BETWEEN '2010-05-01' AND '2010-05-30'

会输出结果
OrderNo CustomerName SalePrice Quantity OrderDate
20100530006 Tyler 9200 50 2010-05-30
20100515029 Alan 100 50 2010-05-29


Example
选择在两个不同大小的数字之间的资料

Sytax : SELECT * FROM table_name WHERE column_name BETWEEN value1 AND value2
SQL
SELECT * FROM Orders WHERE OrderDate BETWEEN 5000 AND 10000

会输出结果
OrderNo CustomerName SalePrice Quantity OrderDate
20100620392 Vincent 7200 5 2010-06-20
20100530006 Tyler 9200 50 2010-05-30

© 2012 PureExample.com contact