Reputation: 381
How to select more than one value from a 'non-existing' table.
For example:
SELECT ('val1', 'val2') as "test"
How to make a column "test" with two values/rows val1 and val2?
Upvotes: 0
Views: 68
Reputation: 9377
To temporarily generate rows with values, PostgreSQL has following options:
VALUES
Lists like VALUES (1, 'one'), (2, 'two'), (3, 'three');
WITH
Queries (Common Table Expressions) common-table-expressionCREATE TABLE TEMPORARY
to create a table for temporary use in this sessionFor small numbers of rows I would suggest the VALUES
expression.
For more rows and usage in complex queries I would suggest the temporary table.
See also:
Upvotes: 1
Reputation: 34
If you use SQL Server family, you can use a query similar to this :
declare @tmpTable as table (test varchar(50))
insert into @tmpTable
select 'val' Go 100
now you can use @tmpTable
Upvotes: 0
Reputation: 722
you can use union
two rows in table like below code:
select 'val1' as "test"
union
select 'val2' as "test"
Upvotes: 1