SQL queries are used in particular pattern and they work in step by step manner to fetch the data from the database tables. It happens in various scenarios that the data required to be fetched from the database, depends upon various conditions and filtration is required to be applied depending upon the specific requirements. For that purposes, there are many functions, keywords and clauses in SQL.
In this tutorial we will focus on one of those clauses, which is where clause in SQL Server.
Step 1- Fetching all records
To better understand the working of where clause in SQL, let us start by fetching all the records from employee table first.
For that write the following, and press F5 to execute:
Select * from EMP
Step 2- Inserting Where Clause
Now, if we want to view the records of only those employees who are managers, we have to use a Where clause and insert Job as a filter and specify managers for Job type.
Hence the query would become:
Select * from EMP
Where Job=’manager’
Press F5 after writing this query to execute.
The result now contains the employees which are only managers.
This is how clauses in SQL are used.