Menu

Monday, 10 February 2014

Difference Between IN Operator and BETWEEN Operator




EmployeeID
EmployeeName
EmployeeMobNo
EmployeeAge
1
Mayank Dixit
9532771738
21
2
Mona Dixit
9005408263
22
3
Purnima
9485754875
23
4
Payal
9785458545
24
5
Singham
8987878775
22
                                                     Employee table

IN Operator:

              This operator is fetch data from table (Employee) which are specified particularly in the where clause (in condition).suppose we specify EmployeeAge IN (22, 24) then data will fetch only EmployeeAge 22 years and 24 years.

 Syntax:

      SELECT * FROM Employee WHERE EmployeeAge IN (22,24);

EmployeeID
EmployeeName
EmployeeMobNo
EmployeeAge
2
Mona Dixit
9005408263
22
5
Singham
8987878775
22
4
Payal
9785458545
24
                                                   In Operator Result table

Above table (Employee) EmployeeAge of Mona Dixit (22 years) and Singham (22 years) and Payal (24 years) respectively so data fetch only 22 years and 24 years.

BETWEEN Operator:

              This operator is specified difference between two row’s data from table (Employee) .suppose we specify EmplyoeeAge BETWEEN (22 years, 24 years) then data will fetch from EmployeeAge 22 years, 23 years, 24 years till.


 Syntax:

      SELECT * FROM Employee WHERE EmployeeAge BETWEEN (22,24);



EmployeeID
EmployeeName
EmployeeMobNo
EmployeeAge
2
Mona Dixit
9005408263
22
5
Singham
8987878775
22
3
Purnima
9485754875
23
4
Payal
9785458545
24
                                                     Between Operator Result table

Above table (Employee) EmployeeAge of Mona Dixit (22 years) and Singham (22 years) and Purniam (23 years) and Payal (24 years) years respectively and I differentiate only data between 22 years to 24 years so data fetch 22 years and 23 years and 24 years.

No comments: