AND: every condition must be true.OR: at least one condition must be true.NOT: reverses a condition.
Use parentheses to control the order when mixing AND and OR: WHERE Country = 'Pakistan' AND (City = 'Lahore' OR City = 'Karachi').
Combine conditions.
✍️ 3 exercises + code challenge in this lessonAND: every condition must be true.OR: at least one condition must be true.NOT: reverses a condition.Use parentheses to control the order when mixing AND and OR: WHERE Country = 'Pakistan' AND (City = 'Lahore' OR City = 'Karachi').
Mastering SQL AND, OR, NOT 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.
SELECT * FROM Customers
WHERE Country = 'Pakistan' AND (City = 'Lahore' OR City = 'Karachi');
SELECT ProductName, Category FROM Products
WHERE NOT Category = 'Electronics';
Check what you learned in “SQL AND, OR, NOT”.
Both conditions must be true.
WHERE Country = 'Pakistan' City = 'Karachi'
Which operator reverses a condition?
Select ProductName of Electronics products that cost less than 5000.
Free sign-in required · Google login available
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