By supplying a condition to the query, a SQL clause is constructed to limit the result set. This typically selects a few rows from the whole collection of records. A query with a WHERE condition is an example of a clause.
Example
Employee Table
emp_id | emp_name | salary | dept_id | manager_id |
---|---|---|---|---|
E1 | Rahul | 15000 | D1 | M1 |
E2 | Manoj | 15000 | D1 | M1 |
E3 | James | 55000 | D2 | M2 |
E4 | Michael | 25000 | D2 | M2 |
E5 | Ali | 20000 | D10 | M3 |
E6 | Robin | 35000 | D10 | M3 |
Query
The following query will return the name of all the employees with salaries greater than 20000.
SELECT emp_name FROM Employee
WHERE salary > 20000;
Output
emp_name |
---|
James |
Michael |
Robin |
Code Runner
Copy the below query in the code runner to see the result
SELECT emp_name FROM Employee
WHERE salary > 20000;