Computer ScienceExam code: 0984
Database Concepts
Databases
When a WHERE clause needs to test more than one condition, AND and OR combine them, exactly like in topic 21.
AND: every condition must be true
SELECT *
FROM Customers
WHERE Age > 18
AND City = 'New York';
Returns only customers who are both older than 18 and living in New York.
OR: at least one condition must be true
SELECT *
FROM Customers
WHERE City = 'London'
OR City = 'Paris';
Returns customers living in either London or Paris.
Multiple combined conditions
SELECT *
FROM Customers
WHERE (Age > 30 AND Country = 'USA')
OR Country = 'France';
Returns customers who are either over-30 USA residents, or any customer from France. Brackets make the meaning unambiguous.
Quick check
3 short questions on this note. See what has stuck, and where to look if something hasn't.
About 1 minute