OR Clause
Advertisements
OR Clause in SQL
OR clause are use to combined two or more than two condition together, In this case you need at least one condition is true then return result.
Suppose you want to get those employee record who have more than 30000 salary or more than 5 year experience in that case you can combined these two condition by using OR clause.
Syntax
SELECT columns FROM tables WHERE condition 1 OR condition 2;
Employee table
emp_id | name | salary | experience |
---|---|---|---|
101 | Amit | 24000 | 3 |
102 | Rahul | 34000 | 10 |
103 | Sultan | 54000 | 2 |
104 | Gaurav | 46000 | 6 |
105 | Hitesh | 35000 | 4 |
Example
SELECT * from Employee WHERE salary>30000 OR experience>5;
Result after using OR clause: Here return those employee records who have satisfy at least one conditon.
emp_id | name | salary | experience |
---|---|---|---|
102 | Rahul | 34000 | 10 |
103 | Sultan | 54000 | 2 |
104 | Gaurav | 46000 | 6 |
105 | Hitesh | 35000 | 4 |
Google Advertisment