SQL BETWEEN option usage
Use the WHERE clause in the BETWEEN relationship to select values BETWEEN various types of data.
BETWEEN relationship
And BETWEEN's choice of a series of values BETWEEN the two countries. The value can be a number, text, or date.
Between SQL syntax
SELECT column_name(s)FROM table_nameWHERE column_nameBETWEEN value1 AND value2
Let's take an example.
P_Id |
LastName |
FirstName |
Address |
City |
1 |
Hansen |
Ola |
Timoteivn 10 |
Sandnes |
2 |
Svendson |
Tove |
Borgvn 23 |
Sandnes |
3 |
Pettersen |
Kari |
Storgt 20 |
Stavanger |
Now, we want to select "Hansen" and "Peterson" in alphabetical order of the person's surname from the above table.
We use the following SELECT statement:
SELECT * FROM PersonsWHERE LastNameBETWEEN 'Hansen' AND 'Pettersen'
The results are as follows.
_Id |
LastName |
FirstName |
Address |
City |
1 |
Hansen |
Ola |
Timoteivn 10 |
Sandnes |
Note: For reprint, please indicate that it is from www.111cn.cn/database/database.html