SQL WHERE

Filter records with conditions.

✍️ 3 exercises + code challenge in this lesson

The WHERE clause keeps only the rows that match a condition.

Operators in WHERE

  • = equal, <> or != not equal
  • >, <, >=, <=
  • BETWEEN, LIKE, IN (covered in later lessons)

Text values need single quotes: WHERE City = 'Lahore'.

Key Takeaways: SQL WHERE

Mastering SQL WHERE helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL WHERE Code Example

SQL
SELECT * FROM Customers
WHERE Country = 'Pakistan';

SELECT ProductName, Price FROM Products
WHERE Price > 20000;
Free sign-in required · Google login available

SQL WHERE Practice Exercises

Check what you learned in “SQL WHERE”.

/ 3 solved
Fill in the blank

Filter customers from Lahore.

SELECT * FROM Customers  City = 'Lahore';
✓ Correct! Not quite. Try again.
Multiple choice

How are text values written in SQL?

✓ Correct! Not quite. Try again.
Code challenge

Select the names of products in the "Furniture" category.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services