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.
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.
Learning SQL in order?
Use the roadmap to follow each SQL topic step by step, from relational database basics to advanced query techniques.
Back to SQL RoadmapRelated lessons
ALTER TABLE
A beginner-friendly guide to ALTER TABLE in SQL, including how to add, change, and remove columns from an existing table.
CREATE TABLE
A beginner-friendly guide to the SQL CREATE TABLE statement, including table planning, column names, data types, and a SQL Server-friendly example.
DELETE
A beginner-friendly guide to the SQL DELETE statement, with SQL Server-friendly examples for removing rows from a table safely.