SQL WHERE Clause (original) (raw)

Last Updated : 14 Apr, 2026

SQL provides the WHERE clause to filter rows based on one or more conditions. It ensures that queries return or modify only the required records.

**Example: First, we will create a demo SQL database and Employees table, on which we will use the WHERE Clause command.

Emp

Employees table

**Query:

SELECT Name, Department, Salary
FROM Employees
WHERE Salary > 50000;

**Output:

Select

**Syntax:

SELECT column1, column2
FROM table_name
WHERE column_name operator value;

Examples of WHERE Clause

We will create a basic employee table structure in SQL for performing all the where clause operation.

Screenshot-where

Example 1: Where Clause with Logical Operators

To fetch records of Employee with age equal to 24.

**Query:

SELECT * FROM Employees WHERE Age=24;

**Output:

Screenshot-2

Example 2: WHERE with Comparison Operators

To fetch the EmpID, Name and Country of Employees with Age greater than 21.

**Query:

SELECT EmpID, Name, Country FROM Employees WHERE Age > 21;

**Output:

Screenshot-3

**Example 3: Where Clause with BETWEEN Operator

The BETWEEN operator is used to filter records within a specified range, and it includes both the start and end values. In this example, we want to find employees whose age is between 22 and 24, including both 22 and 24.

**Query:

SELECT * FROM Employees
WHERE Age BETWEEN 22 AND 24;

**Output:

Screenshot-4

Example 4: Where Clause with LIKE Operator

The LIKE operator is used to filter data by matching a specific pattern in the WHERE clause. In this example, we retrieve records of employees whose names start with the letter 'L'.

**Query:

SELECT * FROM Employees
WHERE Name LIKE 'L%';

**Output:

Like-operator

**Example 5: Where Clause with IN Operator

It is used to fetch the filtered data same as fetched by '=' operator just the difference is that here we can specify multiple values for which we can get the result set. Here we want to find the Names of Employees where Age is 21 or 23.

**Query:

SELECT Name FROM Employees
WHERE Age IN (21,23);

**Output:

SS

Operators Used in WHERE Clause

**Operator **Description
> Greater Than
>= Greater than or Equal to
< Less Than
<= Less than or Equal to
= Equal to
<> Not Equal to
BETWEEN In an inclusive Range
LIKE Search for a pattern
IN To specify multiple possible values for a column