2 Comments
Apr 28, 2021Liked by Alexey Makhotkin

Hold my beer:

select * from (values(2, 'foo'), (5, 'quux'), (7, 'gvar')) tmp(colA, colB);

Valid in SqlServer and PostgreSQL. SQLite won't let you name your columns, but you can get there via a CTE, or omit them entirely if you don't care (they'll be named column1, column2).

I don't know about other databases.

Expand full comment
author

thank you! it's good to have denser option to save on network traffic.

(for reference: https://www.postgresql.org/docs/13/queries-values.html)

Expand full comment