Lesson 6 Beginner Level
6 of 30 lessons

WHERE Clause

Learn how to filter data using WHERE clause with conditions and operators. The WHERE clause is essential for retrieving specific data that meets your criteria.

What is the WHERE Clause?

The WHERE clause in SQL is used to filter records that meet a specific condition. It helps you fetch only the rows that match the criteria defined in the query.

Syntax

SELECT column1, column2
FROM table_name
WHERE condition;

Example

SELECT first_name, salary
FROM employees
WHERE salary > 5000;

This query retrieves the names and salaries of employees earning more than 5000.

Multiple Conditions

SELECT *
FROM employees
WHERE department_id = 90 AND salary >= 6000;

Combines multiple filters using logical operators like AND, OR, and NOT.

Practice Task

  • Write a query to fetch all employees from the IT department.
  • Display employees whose salary is less than 3000.
  • Try using != or <> to filter out a specific job ID.