# FROM

`FROM` supplies the rows read by a SELECT. A source can be a table, a view, a subquery or a table-valued function. Several sources can be combined with a [`JOIN`](https://coordinatordb.com/docs/reference/statements/select/join).

A SELECT without `FROM` evaluates expressions once and returns one row.

## Syntax

```text
FROM [schema.]table [AS alias]
FROM (query) [AS alias]
FROM table_function(arguments) [AS alias]
```

An alias gives a source a short name and disambiguates columns shared by several sources.

## Qualified names

The embedded engine resolves namespaces such as `main`, `temp` and an attached name. `main.orders` names the table in the main namespace.

A server SELECT source can use `database.schema.table` to select a managed database for that statement. This does not change the session's [`USE`](https://coordinatordb.com/docs/reference/statements/use) selection.

## Examples

### Reading a subquery

```sql
CREATE TABLE orders (id INTEGER, amount INTEGER);
INSERT INTO orders VALUES (1, 10), (2, 20), (3, 30);
```

```sql
SELECT selected.id, selected.amount
FROM (
    SELECT id, amount
    FROM orders
    WHERE amount >= 20
) AS selected
ORDER BY selected.id
FORMAT csv;
```

```text
2,20
3,30
```

### Generating rows

```sql
SELECT generate_series AS number
FROM generate_series(1, 3)
FORMAT csv;
```

```text
1
2
3
```

Other table functions expand JSON documents or read confined server files. See [table functions](https://coordinatordb.com/docs/reference/functions/table-functions) for their syntax and restrictions.
