WHERE Clause
Filter rows based on a condition
✅ What You Will Learn
The WHERE clause filters the rows returned by a SELECT query. Without WHERE, SQL returns every row in the table. With WHERE, it returns only the rows that match your condition.
This is how you answer specific business questions: "Show me only orders above ₹10,000" or "Show me only customers from Delhi" — these filters go in the WHERE clause.
WHERE evaluates each row one by one and only includes it in the result if the condition is true.
📋 The orders table used in examples
| order_id | customer_name | product | amount | city |
|---|---|---|---|---|
| 1001 | Rahul Sharma | Laptop | 45000 | Delhi |
| 1002 | Priya Verma | Mobile Phone | 18000 | Noida |
| 1003 | Amit Kumar | Headphones | 3500 | Gurgaon |
| 1004 | Sneha Kapoor | Laptop | 52000 | Delhi |
| 1005 | Vikram Singh | Tablet | 28000 | Noida |
Syntax
Examples
📌 Key Points to Remember
- ✓WHERE goes after FROM in the query
- ✓Text values need single quotes — numbers do not
- ✓Use = for equality, <> or != for not equal
- ✓BETWEEN is inclusive — BETWEEN 10 AND 20 includes 10 and 20
- ✓Dates should be written in YYYY-MM-DD format for safe comparisons
🏢 Real-World Application
WHERE is the clause that makes SQL useful for business questions. "Find all customers who placed orders above ₹50,000 in December 2025" — that is a WHERE clause. "List all employees in the Delhi office who joined after 2023" — WHERE again. At companies like Amazon India or Swiggy, analysts use WHERE every single day to narrow down millions of rows to the specific subset they need for a report. BETWEEN is commonly used for date ranges — WHERE order_date BETWEEN '2026-01-01' AND '2026-01-31' — to pull monthly data. LIKE is used for text searches — WHERE city LIKE '%Delhi%' — to find partial matches in customer addresses.
⚠️ Common Mistakes to Avoid
❓ Frequently Asked Questions
What does the WHERE clause do in SQL?
WHERE filters rows returned by a query. It evaluates each row against a condition and only includes rows where the condition is true. It is used after FROM and before ORDER BY.
What is the difference between WHERE and HAVING in SQL?
WHERE filters individual rows before grouping. HAVING filters groups after GROUP BY has been applied. You cannot use aggregate functions like SUM() or COUNT() in a WHERE clause — use HAVING for that.
How do I filter dates in SQL WHERE clause?
Use the YYYY-MM-DD format for date comparisons: WHERE order_date = '2026-01-15'. For ranges, use BETWEEN: WHERE order_date BETWEEN '2026-01-01' AND '2026-01-31'.
What is LIKE in SQL WHERE clause?
LIKE is used for partial text matching. The % wildcard means zero or more characters. WHERE name LIKE 'R%' finds names starting with R. WHERE city LIKE '%Delhi%' finds any city containing Delhi.
Can WHERE have multiple conditions?
Yes. Use AND to require both conditions to be true, OR to require at least one to be true. Example: WHERE amount > 10000 AND city = 'Delhi' returns only high-value orders from Delhi.
✏️ Practice Exercise
Write a query to find all orders where the amount is between ₹5,000 and ₹20,000.
Learn SQL with Live Trainer Guidance
These tutorials give you the theory. Our live SQL course at EVIKA Academy, Noida teaches you to apply SQL on real company datasets — with a trainer who uses it daily at MakeMyTrip.