(Contents)(Previous)(Next)

Ranges~of Values: BETWEEN x AND y

All rows can be searched which have a value within a specified range.

account BETWEEN -420 AND 0

means that all accounts having a value between -420 and 0 (both values included) will be found. This condition can also be written in the following way:

account >= -420 AND account <= 0.

SELECT title, name, city, account

FROM customer

WHERE account BETWEEN -420 AND 0

Selection of all customers whose name begins with the letter 'B':

SELECT title, name

FROM customer

WHERE name BETWEEN 'Ba' AND 'Bz'

This query can be formulated more 'elegantly' using LIKE. Section Searching For Character Strings contains a description of how this can be done.

Selection of all customers who live in Los Angeles:

SELECT title, name, city, state, zip

FROM customer

WHERE zip BETWEEN 9000 AND 90024


(Contents)(Previous)(Next)