Balakrishnan
Balakrishnan

Reputation: 2441

MySQL list of values as a column

I'm looking for an alternative to this in MySQL https://stackoverflow.com/a/13494329

SQL query:

SELECT tempId
FROM (
        VALUES(1),(2),(3)
    ) V(tempId)

Result:

tempId
  1
  2
  3

Upvotes: 0

Views: 61

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175586

For equivalent of Table Value Constructor in MySQL you can use UNION ALL:

SELECT tempId
FROM (
        SELECT 1 AS tempId
        UNION ALL SELECT 2
        UNION ALL SELECT 3
    ) V

Upvotes: 1

Related Questions