Loading Data Driven Insights
Preparing your learning content.
Preparing your learning content.
A beginner-friendly guide to the SQL WHERE clause, including how to filter rows using text and number conditions in SQL Server.
On this page
Jump to a lesson section
The WHERE clause is used to filter rows in a SQL query.
It helps you return only the rows that match a condition instead of returning every row from the table.
A basic WHERE query follows this pattern.
SELECT
column_name
FROM table_name
WHERE condition;
For example, this query returns only employees from the Sales department.
SELECT
employee_name,
department,
salary
FROM Employees
WHERE department = 'Sales';
We will use this Employees table to understand how WHERE filters rows.
Text values in SQL are usually written inside single quotes.
This query returns only rows where the department is Sales.
SELECT
employee_name,
department,
salary
FROM Employees
WHERE department = 'Sales';
'Sales'.You can also use WHERE with comparison operators such as >, <, >=, <=, and =.
This query returns employees with a salary greater than 40000.
SELECT
employee_name,
department,
salary
FROM Employees
WHERE salary > 40000;
Without WHERE, SQL returns all rows from the selected table.
SQL Roadmap Progress
Topic 18 of 111
16% complete
Next in SQL Roadmap
Continue with the next SQL topic in the recommended roadmap order.
Continue learning →