Home > Blockchain >  SQL: how to select a column with more than one values from non-existing table
SQL: how to select a column with more than one values from non-existing table

Time:12-12

How to select more than one value from a 'non-existing' table.

For example:

SELECT ('val1', 'val2') as "test"

enter image description here

How to make a column "test" with two values/rows val1 and val2?

CodePudding user response:

you can use union two rows in table like below code:

select 'val1' as "test"
union
select 'val2' as "test"

enter image description here

CodePudding user response:

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

  • Related