Values clause in a select statement
You've all seen the VALUES clause before. It is typically used to insert data.
insert into colors (name, brightness)
values ('red', 10), ('black', 0), ('blue', 5);
You can also use the VALUES clause in a select statement:
select * from (values ('red', 10), ('black', 0), ('blue', 5)
);
This is great when experimenting with different parts of sql at the command line.
Additionally, values
is a first class expression on its own:
> values (1,2), (2,3);
column1 | column2
---------+---------
1 | 2
2 | 3
(2 rows)
Tweet