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:

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:

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; 


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


VALUES can also be used in a subquery, after FROM. For example, the following two queries are equivalent:

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

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

SELECT * FROM (VALUES (1,2), (3,4)) as t(x,y);

In this case, the columns will get the names x, y.