Misael Indra Wijaya
Misael Indra Wijaya

Reputation: 23

subquery select with multiple row value

so i have this query

select oldvalue, newvalue from(select 'a' as oldvalue, 'b' as newvalue) as N

now the problem is i can only have 1 value each column when i want to have multiple value in column, i have tried using union all like this

select oldvalue, newvalue from(select 'a' as oldvalue, 'b' as newvalue UNION ALL 'c', 'd') as N

with this now i have a and c as oldvalue and b and d as newvalue, but with union all i can only have 2 max of value in each column, is there a way for me to have more than two value in each column

Upvotes: 0

Views: 61

Answers (1)

Suresh Gajera
Suresh Gajera

Reputation: 362

Just writing in CODE what @TimBiegeleisen has mention in the comment.

  SELECT oldvalue, newvalue 
  FROM ( SELECT 'a' as oldvalue, 'b' as newvalue UNION ALL 
       SELECT 'c', 'd' UNION ALL
       SELECT 'e' ,'f' UNION ALL
       SELECT 'g' ,'h' UNION ALL
       SELECT 'i','j' ......
      ) as N

Upvotes: 1

Related Questions