AND, OR and NOT
AND needs both conditions to be true, OR needs at least one and NOT reverses a condition. AND is evaluated before OR, so use parentheses to make your meaning clear.
Example
SELECT name, country, score
FROM students
WHERE country = 'Nigeria' AND score > 85;Result
name | country | score Ada | Nigeria | 92 Zainab | Nigeria | 88
Example
SELECT name, country
FROM students
WHERE country = 'Ghana' OR country = 'Kenya';Result
name | country Kofi | Ghana Wanjiru | Kenya Esi | Ghana
Example
SELECT name, country
FROM students
WHERE NOT country = 'Nigeria';Result
name | country Kofi | Ghana Wanjiru | Kenya Sipho | South Africa Esi | Ghana
Exercise
Require both conditions.
SELECT * FROM students WHERE country = 'Ghana' score > 70;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.