The BETWEEN operator selects a range of data between two values. The values can be numbers, text, or dates.
Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
The "Custmast" Table ( Note Date Format ( MM/DD/YYYY)
custcode
|
Date
|
custname
|
city
|
rate
|
1
|
Siva
|
Srivilliputtur
|
70
|
|
2
|
Bala
|
Sivakasi
|
56
|
|
3
|
Kanna
|
200
|
||
4
|
Vijay
|
Chennai
|
30
|
|
5
|
Kodee
|
Sandnes
|
80
|
|
5
|
Kodee
|
Srivilliputtur
|
30
|
Example: 1
SELECT *
FROM custmast
WHERE Date BETWEEN '01/01/2009' and '6/08/2011'
Output :
custcode
|
Date
|
custname
|
city
|
rate
|
2
|
Bala
|
Sivakasi
|
56
|
|
3
|
Kanna
|
200
|
||
4
|
Vijay
|
Chennai
|
30
|
Example: 2
SELECT *
FROM custmast
WHERE custcode BETWEEN 1 and 3
Output :
custcode
|
Date
|
custname
|
city
|
rate
|
1
|
Siva
|
Srivilliputtur
|
70
|
|
2
|
Bala
|
Sivakasi
|
56
|
|
3
|
Kanna
|
200
|
No comments:
Post a Comment