3

I can add virtual columns as

SELECT '1' as id

| id |
-------
|  1 | 

But I want add multiple values, example:

SELECT ('1','2','3') as id

| id |
-------
|  1 | 
|  2 | 
|  3 | 

But this don't work

Piotr
  • 31
  • 1
  • 4
  • 1
    SELECT 1 id UNION SELECT 2 UNION SELECT 3 – Strawberry Mar 12 '15 at 16:24
  • you can't have a single query split a single row into multiple rows, but you can have multiple queries, each producing one of the values, by chaining them together with `union`. – Marc B Mar 12 '15 at 16:25

1 Answers1

0

Like Marc B said in a comment you can't have a single query split a single row into multiple rows, but you can have multiple queries, each producing one of the values, by chaining them together with union.

SELECT 1 id 
UNION 
SELECT 2 
UNION 
SELECT 3

As the answer was provided in a couple of comments I'll post it as a community wiki.

jpw
  • 44,361
  • 6
  • 66
  • 86