0

I'm trying to do a query that will turn a list of literal values into a result set, but I can't quite figure out the syntax without doing a union.

Here are a couple things I've tried:

SELECT *
FROM (1, 2, 3, 5, 6) temp(id);

select x.* from 
(('test-a1', 'test-a2'), ('test-b1', 'test-b2'), ('test-c1', 'test-c2')) x(col1, col2);

Something like that where I'm expecting a result set that looks like:

id
1
2
3
4
5
etc…

or

col1 | col2
test-a1, test-a2
test-b1, test-b2
test-c1, test-c2
etc…
0

2 Answers 2

1
CREATE TEMPORARY TABLE temp_id_table
( id INT UNSIGNED NOT NULL );

INSERT INTO temp_id_table ( id ) VALUES
(1),(2),(3),(4),(5)
;

select id from temp_id_table;

results:

id
1
2
3
4
5
Sign up to request clarification or add additional context in comments.

Comments

0

Create a temp table, insert those values to the temp table then query your temp table.

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.