Where Clause
Advertisements
Where Clause
Where Clause is used to extract only those records that satisfied the given condition, like fetch only those employee record which have more than 30000 salary.
When use where clause ?
- To retrive only specific record
- To delete only specific record
- To update only specific record
Syntax
SELECT column_name,column_name FROM table_name WHERE column_name operator value;
Employee table
emp_id | name | salary |
---|---|---|
101 | Amit | 24000 |
102 | Rahul | 34000 |
103 | Sultan | 54000 |
104 | Gaurav | 26000 |
105 | Hitesh | 35000 |
Example
SELECT * from Employee WHERE salary>30000;
Result after Execute above query.
emp_id | name | salary |
---|---|---|
105 | Hitesh | 35000 |
102 | Rahul | 34000 |
103 | Sultan | 54000 |
Operators in The WHERE Clause
WHERE clause uses some conditional selection, which is given below;
Operator | Description | |
---|---|---|
1 | = | Equal |
2 | <> | Not equal. Note: In some versions of SQL this operator may be written as != |
3 | > | Greater than |
4 | < | Less than |
5 | >= | Greater than or equal |
6 | <= | Less than or equal |
7 | BETWEEN | Between an inclusive range |
8 | LIKE | It is used to search for a pattern |
9 | IN | It is used to specify multiple possible values for a column |
Google Advertisment