MainMenu

Home Core Java Overview Maven Tutorials

Sunday, 15 January 2017

Difference between IN and Between statement

SQL IN and BETWEEN Statement

IN operator used to select the record which are matching within IN condition. where as Between operator used to specify a range to select records.
Consider the below table : Salary
Emp_idEmp_nameEmp_regEmp_salarycity
01chandanE_0125000Noida
02adhirajE_0230000noida
03raghuE_0335000Noida
04raghunathE_0436000Noida
05AlaxE_0540000Noida
IN Query Syntax :

Select column_name, column_name from table_name Where column_name IN("value1","value2", "Value3")


Select * from salary Where Emp_salary IN(20000, 30000) Result :

Only records which are matching under IN condition will appear

Emp_idEmp_nameEmp_regEmp_salarycity
02adhirajE_0230000noida
Between Query Syntax :

Select column_name, column_name from table_name Where column_name between "value1" and "value2"


Select * from salary Where Emp_salary BETWEEN 20000 and 30000 Result :

All the records which are matching within BETWEEN condition will appear

Emp_idEmp_nameEmp_regEmp_salarycity
01chandanE_0125000Noida
02adhirajE_0230000noida

Tag :SQL IN with Example, SQL Between with Example

No comments:

Post a Comment