Search⌘ K
AI Features

Filtering Rows with WHERE

Explore how to filter database rows using the WHERE clause in SQL. Learn to apply comparison operators and combine multiple conditions with AND and OR to retrieve targeted data. This lesson helps you write logic-based queries to select only relevant information from tables like employees, enhancing data analysis precision.

Step 1: Start with a question

In Module 1, your queries returned everything. Now let’s get selective. Imagine you work with a table called employees. You might ask:

Write an SQL query to show which employees work in the Engineering department.

This time, you don’t want the entire table, just the rows that meet a specific condition.

Powered by AI
5 Prompts Remaining
Prompt AI WidgetOur tool is designed to help you to understand concepts and ask any follow up questions. Ask a question to get started.

Write a SQL query that shows the first name, last name, and department of employees who work in the Engineering department.

Step 2: Run and observe

AI might return:

MySQL
SELECT first_name, last_name, department
FROM employees
WHERE department = 'Engineering';

Run it. Notice how you’re now ...