I have these 2 selects (select 1, 'a') and (select 2, 'b', 'x') and I want an output like 1, 'a', 2, 'b', 'x' can I do this in postgres without altering the selects?
I tried this:
select (select 1, 'a'), (select 2, 'b', 'x')
but the error is "subquery must return only one column".
CodePudding user response:
I think what you're looking for is the CONCAT function.
This link should help you: https://www.postgresqltutorial.com/postgresql-concat-function/
You'll probably be looking at some form of SELECT CONCAT(SELECT 1, SELECT 2, ...), but not 100% sure.
CodePudding user response:
This works
select *
from (select 1, 'a') as a
left join (select 2, 'b', 'x') as b on (1=1)
is inspired from here Union select statements horizontally
Also Syed Mushtaq comment works and seems easier to write.