Thuta Learning
BasicData & Databasesbeginner

AND, OR, NOT

Relax. We'll talk through this in plain words — no textbook voice.

AND, OR, NOT are used when you need to check more than one condition. They're essential for building filter systems.

AND — result shows up only if all conditions are true

OR — result shows up if any one condition is true

NOT — grabs rows where the condition is NOT true

Tip

When you have several conditions, use parentheses () to keep your logic clear and easy to follow.

sql
SELECT CustomerName, City, Country
FROM Customers
WHERE Country = 'Mexico' OR Country = 'Germany';
You should see
+--------------------+-------------+---------+ | CustomerName | City | Country | +--------------------+-------------+---------+ | Alfreds Futterkiste| Berlin | Germany | | Ana Trujillo | Mexico City | Mexico | | Antonio Moreno | Mexico City | Mexico | +--------------------+-------------+---------+ What this code does: It shows customers who are either from Germany or from Mexico. Common mistake: Mixing AND and OR without care can produce results you don't expect, because of operator precedence. When in doubt, use parentheses.