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_id | Emp_name | Emp_reg | Emp_salary | city |
---|---|---|---|---|
01 | chandan | E_01 | 25000 | Noida |
02 | adhiraj | E_02 | 30000 | noida |
03 | raghu | E_03 | 35000 | Noida |
04 | raghunath | E_04 | 36000 | Noida |
05 | Alax | E_05 | 40000 | Noida |
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_id | Emp_name | Emp_reg | Emp_salary | city |
---|---|---|---|---|
02 | adhiraj | E_02 | 30000 | noida |
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_id | Emp_name | Emp_reg | Emp_salary | city |
---|---|---|---|---|
01 | chandan | E_01 | 25000 | Noida |
02 | adhiraj | E_02 | 30000 | noida |
No comments:
Post a Comment