WHERE Clause in SQL

‘Where’ as a term is used to define a location or position and this is exactly what the clause does in the SQL Where. Where in SQL a condition is defined while the data is being fetched. The Where in SQL only fetches the necessary data.

How to Filter Records with the ‘Where’ in SQL?

Where in SQL records are filtered based on a condition, or where they are used to extract records that satisfy a condition. In this case, we want to remove those records where a person’s age is over fifty or sixty from those records where the person’s occupation is a doctor.

Where Clause Syntax in SQL with an Example

SELECT column1, column2, columnN
FROM tablename
WHERE [condition];

Where the keywords are Pick, FROM, and WHERE; column1 to columnN is a set of columns; tablename is the table name, and a condition followed by a semicolon.

Let’s display only the employees from the operations department

select e_name,e_dept from employee where e_dept=’operation’;

Where Clause in SQL

After the query is written, click the execute button to check for errors

The table will appear after the query has been executed

This takes us to the end of this where in SQL. We will address the defined operators used with the Where clause in the next tutorial segment which will help users filter data using multiple constraints.

Leave a Reply