We're making some improvements. Some features may be temporarily unavailable.
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

OperatorMeaningExample
=Equal toWHERE name = 'Alice'
!= or <>Not equalWHERE id != 5
> <Greater/less thanWHERE score > 80
>= <=Greater/less or equalWHERE age >= 18
BETWEENIn a rangeWHERE date BETWEEN '2026-01-01' AND '2026-12-31'
LIKEPattern matchWHERE name LIKE 'A%' (starts with A)
INIn a listWHERE id IN (1, 3, 5)
IS NULLIs emptyWHERE 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

Questions & Discussion

Sign in to ask a question or join the discussion.

Loading comments...