Whereas the SQL IN keyword help people to limit
the selection criteria to one or more discrete
values, now in SQL Tutorial you will learn that the SQL BETWEEN keyword allows for selecting a range.
The syntax for the SQL BETWEEN clause is as follows:
This will select all rows whose column has a value between
'value1' and 'value2'.
For example, we may wish to view all records form the Employees table and
criteria is this that we need to view only those employees record who are having
date of birth BETWEEN 1972 to 1978.
| FirstName |
LastName |
Email |
DOB |
Phone |
| Austin |
Hennery |
austin.it@gamail.com |
24/11/1979 |
446 102-2222 |
| Creston |
Narvon |
narvon_crest@hotmail.com |
22/04/1976 |
443 325-4545 |
| Kate |
Bladen |
kbladen@usa.net |
01/05/1973 |
326 503-3232 |
| Angela |
Julie |
julieee@yahoo.co.uk |
11/12/1977 |
326 323-8888 |
| Bobbi |
Ferguson |
bobi123@kiwibox.com |
10/02/1970 |
506 252-9875 |
| Cute |
Alfa |
cafa@gmail.com |
19/05/1971 |
506 272-4566 |
Note that date may be stored in different formats in different databases. This tutorial simply choose one of the formats.