| SQL Advanced |
| |
| SQL BETWEEN |
| |
| BETWEEN ... AND |
| The BETWEEN ... AND operator selects a range of data between two values. These values can be numbers, text, or dates. |
| |
|
| |
| |
| Original Table (used in the examples) |
| |
|
| |
|
| |
| Result: |
|
| |
| |
| IMPORTANT! The BETWEEN...AND operator is treated differently in different databases. With some databases a person with the LastName of “seth” or “mittal " will not be listed (BETWEEN..AND only selects fields that are between and excluding the test values). |
| |
| Example 2 |
| To display the persons outside the range used in the previous example, use the NOT operator: |
| |
|
| |
| Result: |
|
| |
| |
|
|
| |
| |