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

2
  • 1
    SELECT 1 id UNION SELECT 2 UNION SELECT 3 Commented Mar 12, 2015 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. Commented Mar 12, 2015 at 16:25

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.