SELECT & WHERE
What you will learn
How to read data from a database table using SELECT and filter rows with WHERE.
Basic SELECT
SELECT * FROM users;
The star means "all columns". Always returns a table of results.
SELECT name, email FROM users;
Name only the columns you need — faster and clearer.
Filtering with WHERE
SELECT * FROM users WHERE age >= 18;
Operators: =, !=, <, >, <=, >=, LIKE, IN, BETWEEN.
SELECT name FROM users WHERE city = 'London' AND age > 21;
Combine conditions with AND, OR, NOT.
Common mistakes
- Forgetting single quotes around string values:
city = London(wrong),city = 'London'(right) - Using
=instead of==for equality — SQL uses single=
Quick check below!