# FROM

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: FROM
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-clauses/from/from
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-clauses/from/from.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-clauses/from/from.adoc
description: The FROM clause specifies the tables that a query reads data from.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/from.md -->

The `FROM` clause specifies the tables that a query reads data from.

## [](#syntax)Syntax

A `FROM` clause must list at least one table:

```sql
query FROM table_name;
```

If two or more tables are listed, they are joined with one of: [JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/join/), [RIGHT JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/right-join/), [LEFT JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/left-join/), or [OUTER JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/outer-join/).

```sql
FROM table1_name
[ { JOIN
  | LEFT JOIN
  | RIGHT JOIN
  | OUTER JOIN } table2_name
ON table1_name.column1 = table2_name.column1 ]
```

> 📝 **NOTE**
>
> These examples use the `public` schema, the default in Redpanda SQL. For information on creating or displaying tables in other schemas, see [Schema](https://docs.redpanda.com/cloud-data-platform/reference/sql/schema/).

## [](#examples)Examples

This example uses the `FROM` clause with a single table. Given a `client` table, the goal is to retrieve the client’s name and the city where the company is based.

```sql
CREATE TABLE client (
  client_id int,
  client_name text,
  client_origin text
);
INSERT INTO client
    (client_id, client_name, client_origin)
VALUES
    (181891,'Toyota','Japan'),
    (181892,'Google','USA'),
    (181893,'Samsung','South Korea');
```

```sql
SELECT * FROM client;
```

This returns:

```sql
+------------+--------------+------------------+
| client_id  | client_name  | client_origin    |
+------------+--------------+------------------+
| 181891     | Toyota       | Japan             |
| 181892     | Google       | USA              |
| 181893     | Samsung      | South Korea      |
+------------+--------------+------------------+
```

1.  Run the following query:

    ```sql
    SELECT client_name, client_origin FROM client;
    ```

2.  The query returns:

    ```sql
    +--------------+------------------+
    | client_name  | client_origin    |
    +--------------+------------------+
    | Toyota       | Japan             |
    | Google       | USA              |
    | Samsung      | South Korea      |
    +--------------+------------------+
    ```


> 💡 **TIP**
>
> For multi-table queries, see: [JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/join/), [RIGHT JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/right-join/), [LEFT JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/left-join/), or [OUTER JOIN](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-clauses/from/outer-join/).

## [](#subqueries-with-from)Subqueries with FROM

The `FROM` clause can also specify a subquery. The result of the subquery becomes a new relation that the outer query can reference.

> 📝 **NOTE**
>
> You can list more than one table by separating them with a comma (`,`). This is an implicit (cross) join: `FROM t1, t2 WHERE t1.id = t2.id` is equivalent to `FROM t1 JOIN t2 ON t1.id = t2.id`. Without a `WHERE` clause, the result is the Cartesian product of all rows in both tables.

### [](#syntax-2)Syntax

```sql
SELECT X.column1, X.column2, X.column3
FROM table_2 as X, table_1 as Y
WHERE conditions (X.column, Y.column);
```

1.  The subquery in the first `FROM` clause selects the columns from the specific table using a new temporary relation (`SELECT X.column1, X.column2, X.column3 FROM`).

2.  Set the tables into a new temporary relation (`table_2 as X, table_1 as Y`).

3.  The query is evaluated, selecting only those rows from the temporary relation that fulfill the conditions stated in the `WHERE` clause.


### [](#example)Example

The following example finds a product whose price exceeds the average budget across all categories.

```sql
CREATE TABLE product (
  id int,
  product text,
  category text,
  price int
);
INSERT INTO product
    (id, product, category, price)
VALUES
    (445747,'Court vision women''s shoes nike','Shoes', 8000),
    (445641,'Disney kids h&m','Shirt', 6500),
    (477278,'Defacto adidas','Hat', 8500),
    (481427,'Sophie shopping bag','Bag', 6500),
    (411547,'Candy skirt zara','Skirt', 6500),
    (488198,'Slim cut skirt hush puppies','Skirt', 7600);
```

```sql
SELECT * FROM product;
```

This returns:

```sql
+---------+----------------------------------+-----------+--------+
| id      | product                          | category  | price  |
+---------+----------------------------------+-----------+--------+
| 445747  | Court vision women's shoes nike  | Shoes     | 8000   |
| 445641  | Disney kids h&m                  | Shirt     | 6500   |
| 477278  | Defacto adidas                   | Hat       | 8500   |
| 481427  | Sophie shopping bag              | Bag       | 6500   |
| 411547  | Candy skirt zara                 | Skirt     | 6500   |
| 488198  | Slim cut skirt hush puppies      | Skirt     | 7600   |
+---------+----------------------------------+-----------+--------+
```

Create a `category` table:

```sql
CREATE TABLE category (
  categoryName text,
  budget int
);
INSERT INTO category
    (categoryName, budget)
VALUES
    ('Shoes', 7000),
    ('Shirt', 9000),
    ('Bag', 8000),
    ('Skirt', 7500),
    ('Hat', 7000);
```

```sql
SELECT * FROM category;
```

This returns:

```sql
+---------------+----------+
| categoryName  | budget   |
+---------------+----------+
| Shoes         | 7000     |
| Shirt         | 9000     |
| Bag           | 8000     |
| Skirt         | 7500     |
| Hat           | 7000     |
+---------------+----------+
```

1.  Run the following query to find the average budget across all categories:

    ```sql
    select avg(budget) as avgBudget from category;
    ```

2.  The query returns the average budget across all categories:

    ```sql
    +--------------------+
    | avgbudget          |
    +--------------------+
    | 7700.000000000000  |
    +--------------------+
    ```

3.  Run:

    -   The `product` table is aliased as `P` and the budget’s average value from the `category` table as `C`.

    -   The query displays the product’s name, category, and price.

    -   The conditions are set where the product’s price exceeds the budget’s average value.

        ```sql
        select P.product, P.category, P.price from
        (select avg(budget) as avgBudget from category) as C, product as P
        where P.price > C.avgBudget;
        ```


4.  The query returns the products with a price greater than 7700:

    ```sql
    +------------------------------------+-----------+----------+
    | product                            | category  | price    |
    +------------------------------------+-----------+----------+
    | Court vision women's shoes nike    | Shoes     | 8000     |
    | Defacto adidas                     | Hat       | 8500     |
    +------------------------------------+-----------+----------+
    ```