Home / SQL / Reference / Querying

SQL FROM

Say which table (or tables, or subquery) the rows come from.

Syntax

SELECT … FROM table [AS alias];

FROM is the first clause the database actually runs. It can name a table, a view, a subquery (with an alias) or several tables joined together.

Example

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

SELECT c.name, c.country
FROM customers AS c
LIMIT 5;

Result

namecountry
Aarav SharmaNew Zealand
Mia ChenAustralia
Liam WalkerAustralia
Sita GurungAustralia
Noah BrownAustralia

5 rows

Related

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