Home / SQL / Reference / Querying

SQL SELECT

Choose which columns (or calculations) a query returns.

Syntax

SELECT column1, column2, expression AS alias
FROM table;

Every query that reads data starts with SELECT. * means every column. Each item can be a column, a calculation or a function, renamed with AS.

Example

Query (on the shop database used in the SQL course)

SELECT name, price, price * 1.1 AS price_with_gst
FROM products
LIMIT 5;

Result

namepriceprice_with_gst
Wireless mouse29.031.9
Mechanical keyboard119.0130.9
USB-C hub49.053.9
27-inch monitor329.0361.9
Noise-cancelling headphones249.0273.9

5 rows

Good to know. List the columns you need rather than * in real queries.

Related

Learn it step by step in the free lesson SELECT: Choosing Columns, with exercises that check your queries.