WHERE Condition in SQL
The WHERE condition is one of the most important clauses in SQL for filtering records according to a specific condition. It allows you to retrieve only the rows that match the given criteria, making data extraction more precise.
The WHERE condition can be used with SELECT, UPDATE, and DELETE statements and plays an important role in performing database operations on relevant records.
Table of Contents

Complete Advance AI Topics: Click Here
SQL Tutorial: Click Here
Understanding the WHERE Condition
The WHERE condition is used when retrieving information from a single table or from multiple joined tables. When the specified condition is satisfied, only the matching rows are returned.
This makes it easier to obtain the required records instead of processing or displaying unrelated data.
Syntax of WHERE Condition
SELECT column1, column2, ..... columnN
FROM table_name
WHERE {condition};
Key Points About WHERE Condition
- The WHERE condition is not restricted to SELECT; it can also be used with UPDATE and DELETE statements.
- It supports different comparison and logical operators, including
=,>,<,LIKE,NOT,BETWEEN, andIN. - It can be case-sensitive in some databases, and string values require exact matching within single quotes (
'').
Example of WHERE Condition in SQL
Let’s consider a sample table named EMPLOYEES containing employee information:
| EmployeeID | EmployeeName | Department | Age | Salary |
|---|---|---|---|---|
| 101 | Aryan Sharma | IT | 27 | 55000.00 |
| 102 | Meera Raj | HR | 30 | 62000.00 |
| 103 | Sohan Verma | Finance | 28 | 48000.00 |
| 104 | Kiran Das | Marketing | 32 | 72000.00 |
| 105 | Rohan Mehta | IT | 26 | 51000.00 |
Fetching Employees with Salary Greater than 50,000
To retrieve the EmployeeID, EmployeeName, and Salary of employees whose salary is greater than 50,000, use the following query:
SELECT EmployeeID, EmployeeName, Salary
FROM EMPLOYEES
WHERE Salary > 50000;
Output
| EmployeeID | EmployeeName | Salary |
|---|---|---|
| 101 | Aryan Sharma | 55000.00 |
| 102 | Meera Raj | 62000.00 |
| 104 | Kiran Das | 72000.00 |
| 105 | Rohan Mehta | 51000.00 |
Fetching Employee Details by Name
If you want to retrieve the details of a particular employee, such as Sohan Verma, you can use the following query:
SELECT EmployeeID, EmployeeName, Salary
FROM EMPLOYEES
WHERE EmployeeName = 'Sohan Verma';
Output
| EmployeeID | EmployeeName | Salary |
|---|---|---|
| 103 | Sohan Verma | 48000.00 |
Important Notes
- String values should always be enclosed within single quotes, such as
'Sohan Verma'. - Numeric values do not require quotation marks.
- The WHERE condition can be combined with logical operators such as AND, OR, and NOT to create more complex filters.
Download New Real Time Projects :- Click here
Complete Advance AI topics:-
Conclusion
The WHERE condition is a fundamental SQL clause used to filter data efficiently. Whether you are retrieving specific records, updating selected values, or removing unwanted records, the WHERE clause helps ensure that database operations are performed on the required data.
Understanding and mastering the WHERE condition is essential for anyone working with SQL databases.
SEO Keywords
sql where multiple conditions, where clause in sql example, having clause in sql, order by clause in sql, group by clause in sql, sql where clause multiple values, having clause with where condition in sql, select clause in sql, order by in sql, WHERE Condition in SQL, like in sql, where condition in sql w3schools, where condition in sql server