SQL · Course navigation

SQL SELECT

Read rows from a table.

On this page

The concept

SELECT names the columns to return. WHERE filters rows. ORDER BY controls their order.

Code example

SQL
SELECT name, score
FROM students
WHERE score >= 80
ORDER BY score DESC;

Follow the code

Open the walkthrough to inspect the example one step at a time.

Show guided walkthrough
Guided walkthroughReady
1SELECT name, score
2FROM students
3WHERE score >= 80
4ORDER BY score DESC;

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Request the name and score columns.—
—
Read rows from students.—
—
Keep only rows whose score is at least 80.—
—
Sort the remaining rows by score, highest first. Actual rows depend on table data.—
—

Behind the scenes

How SQL processes this code

The database parses and plans the query, accesses the table, and returns the selected rows. Physical execution order may differ from the query’s written order.