Back to SQL Notes
Topic #82

SQL WHERE Clause

WHERE filters rows before they're returned — only rows matching the condition make it into the result.

Syntax

SELECT columns
FROM table_name
WHERE condition;

Sample Table: employees

idnamedepartmentsalary
1AmanEngineering65000
2RiyaMarketing52000
3KaranEngineering71000

Example

SELECT name, salary
FROM employees
WHERE salary > 60000;

Output:

namesalary
Aman65000
Karan71000

Comparison Operators

OperatorMeaning
=equal to
<> or !=not equal to
>, <greater than, less than
>=, <=greater than or equal, less than or equal

Combining Conditions

SELECT name FROM employees
WHERE department = 'Engineering' AND salary > 60000;

See AND / OR for combining multiple conditions in detail.

Practical Use Case

Almost every real query has a WHERE clause — active users only, orders from this month, products in stock. It's the difference between "all the data" and "the data that actually answers the question."

Common Mistakes

  • Confusing WHERE (filters individual rows, runs before grouping) with HAVING (filters grouped results, runs after grouping) — see WHERE vs HAVING
  • Using = to compare against NULL — this never matches; use IS NULL instead
  • Forgetting quotes around string/date literals: WHERE department = Engineering is invalid — it must be 'Engineering'

Interview Relevance

Filtering logic shows up in nearly every SQL interview question. Interviewers are often less interested in the syntax and more in whether you correctly translate a business requirement ("active customers who spent over ₹10,000 last quarter") into the right conditions.

Practice Question

Write a query to find all employees in the "Marketing" department earning less than 55,000.

Want to go beyond the notes?

Join Coding Now Tech Institute's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

SQL WHERE Clause – FAQs

Quick answers about learning SQL WHERE Clause in SQL.

This free note from Coding Now Tech Institute explains SQL WHERE Clause in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on Coding Now Tech Institute, including SQL WHERE Clause, is 100% free with no signup required.
With focused practice, most students grasp SQL WHERE Clause in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now