beginner25 min
SELECT, WHERE & Filtering
Retrieve data with SELECT, filter with WHERE, and sort with ORDER BY
Querying Data with SELECT
SELECT is the most important SQL command — it retrieves data from your tables.
Basic SELECT
Output
Run your code to see output here
Filtering with WHERE
The WHERE clause filters rows based on conditions:
Output
Run your code to see output here
Comparison Operators
| Operator | Meaning | Example |
|---|---|---|
= | Equal to | WHERE name = 'Alice' |
!= or <> | Not equal | WHERE id != 5 |
> < | Greater/less than | WHERE score > 80 |
>= <= | Greater/less or equal | WHERE age >= 18 |
BETWEEN | In a range | WHERE date BETWEEN '2026-01-01' AND '2026-12-31' |
LIKE | Pattern match | WHERE name LIKE 'A%' (starts with A) |
IN | In a list | WHERE id IN (1, 3, 5) |
IS NULL | Is empty | WHERE email IS NULL |
Sorting with ORDER BY
Output
Run your code to see output here
Limiting Results
Output
Run your code to see output here
Check Your Understanding
Which query finds all students whose name starts with 'A'?
Exercise
Write a SELECT query that returns the names and emails of students enrolled after January 1, 2026, sorted alphabetically by name.
Python will load on first run