First SELECT
Read values with SELECT
SELECT requests values without changing stored rows in these simple examples. FROM names the table to read. Write the column names separated by commas; the result contains those columns. The semicolon marks the end of a statement in typical SQL clients.
Your first product query
The following examples read the shop fixture. ORDER BY id requests ascending identifier order by default so that output is predictable; sorting will be taught in depth later. The first query returns IDs and names; the second returns IDs and prices.
Try the examples
Static SQL — run in the prepared lab.
SELECT id, name FROM products ORDER BY id;Expected rows (JSON notation):
[[1, "Notebook"], [2, "Pen"], [3, "Bag"], [4, "Pencil"]]Static SQL — run in the prepared lab.
SELECT id, price_cents FROM products ORDER BY id;Expected rows (JSON notation):
[[1, 350], [2, 150], [3, 2400], [4, 100]]Practice
Change the selected columns to name only, keeping ORDER BY id. Predict the output before running it. Do not put quotes around a column name as if it were a text value.