JetSQL » Operators » BETWEEN ... AND ...

Syntax:
SELECT * | fieldlist FROM table
WHERE expression [ NOT ] BETWEEN start_value AND end_value
fieldlist
The list of fields that are to be retrieved from the table.
table
The name of the table from which the information is being retrieved.
expression
The field on which to test for the range specified by the start_value and end_value.
start_value
The parameter that indicates the starting position of the range being searched.
end_value
The parameter that indicates the ending position of the range being searched.

The BETWEEN ... AND operator is used to specify a selection criteria by requiring an expression to be equal to one of, or fall between the range defined by, two values.

These values can be numbers, characters, strings, or dates, but you cannot use any wildcard characters. The characters, strings, and dates must be enclosed by a pair of single quotes.

Examples

Code:
SELECT Title FROM ElvisSongs
WHERE ReleaseDate BETWEEN #1/1/56# AND #12/31/57#
Output:
Title
Heartbreak Hotel
Blue Suede Shoes
Jailhouse Rock
Teddy Bear


(4 row(s) affected)
Explanation:

In this query, we search for song titles released from 1956 until 1957.

Language(s): MS SQL Server
Code:
SELECT Title FROM ElvisSongs
WHERE ReleaseDate NOT BETWEEN #1/1/56# AND #12/31/57#
Output:
Title
Hard Headed Woman
My Wish Came True
A Big Hunk of Love
Stuck on You
Crying in the Chapel
Suspicious Minds

(6 row(s) affected)
Explanation:

This query uses the NOT operator to search for values that lie outside the range specified.

Language(s): MS SQL Server