---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ytsaurus.tech/docs/en/yql/syntax/values.md
  - https://ytsaurus.tech/docs/ru/yql/syntax/values.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ytsaurus.tech/docs/en/llms.txt

# Basic VALUES syntax in YQL

## VALUES as a top-level operator

It lets you create a table from specified values. For example, this statement creates a table of k columns and n rows:

```yql
VALUES (expr_11, expr_12, ..., expr_1k),
       (expr_21, expr_22, ..., expr_2k),
       ....
       (expr_n1, expr_n2, ..., expr_nk);

```

This statement is totally equivalent to the following one:

```yql
SELECT expr_11, expr_12, ..., expr_1k UNION ALL
SELECT expr_21, expr_22, ..., expr_2k UNION ALL
....
SELECT expr_n1, expr_n2, ..., expr_nk;

```

#### Example

```yql
VALUES (1,2), (3,4);
```


## VALUES after FROM

VALUES can also be used in a subquery, after [FROM](https://ytsaurus.tech/docs/en/yql/syntax/select/from.md). For example, the following two queries are equivalent:

```yql
VALUES (1,2), (3,4);
SELECT * FROM (VALUES (1,2), (3,4));
```

In all examples above, column names are assigned by YQL as `column0 ... columnN`. To assign arbitrary column names, you can use the following construct:

```yql
SELECT * FROM (VALUES (1,2), (3,4)) as t(x,y);
```
In this case, the columns will get the names `x`, `y`.


