Part 2 of 5 · 1 min read
SELECT: asking for rows
Reading data out of a table, optionally filtered.
Think of asking a librarian for every book by one specific author. The librarian does not hand over the whole library. They hand over only the matching books.
In plain words: SELECT reads rows out of a table. It names which columns to return, which table to read from, and optionally a condition narrowing which rows qualify. Without a condition, every row in the table is returned.
A worked example. Asking for every order a specific customer placed means naming the columns, the table, and the condition.
The key lines.
SELECT order_id, placed_on FROM orders WHERE customer_id = 107;
SELECT, WHERE
SELECT is the SQL statement that reads rows from a table. WHERE is the clause that filters which rows qualify, based on a condition.
Example: SELECT order_id, placed_on FROM orders WHERE customer_id = 107 reads only the orders belonging to customer 107.