The SELECT Statement
How to choose which columns to retrieve from a table
What is SELECT?
Every SQL query to retrieve data starts with SELECT. It tells the database which columns you want to see in your results. By itself, SELECT doesn't filter rows or sort anything — it simply picks the columns.
The basic structure of a query is:
SELECT column1, column2 FROM table_name;
The database will return every row in the table, but only the columns you listed.
Selecting specific columns
List the column names you want, separated by commas. Only those columns will appear in the output — all others are hidden.
-- Return only the drink type and price from every row SELECT drink_type, price_usd FROM coffee_shop_sales;
Column names must match exactly how they appear in the table (including underscores). The order you list them is the order they appear in your results.
Selecting all columns with *
SELECT * is a shorthand that means "give me every column". It's useful for quickly exploring a table when you don't yet know what columns exist.
-- Return every column and every row SELECT * FROM coffee_shop_sales;
In production queries it's usually better to name your columns explicitly — it makes queries easier to understand and avoids surprises if the table structure changes.
💡 Quick reference
| Goal | Syntax |
|---|---|
| Return specific columns | SELECT col1, col2 FROM table; |
| Return all columns | SELECT * FROM table; |
| Return one column | SELECT col1 FROM table; |
Common mistakes
Typos in column names — if you write drink_Types instead of drink_type, the database will return an error. Column names are usually case-insensitive in SQL, but underscores and spelling must be exact.
Missing commas — every column name after the first must be preceded by a comma. SELECT drink_type price_usd will fail; SELECT drink_type, price_usd is correct.
Forgetting FROM — SELECT always needs a FROM clause to know which table to pull from.
Practice: SELECT
Apply what you learned above. Write a query that matches each task.
Table Schema
Task
Tip: Ctrl + Enter to submit