SQL return on different columns, not on rows

4

I am testing a query, where I would need the returns to come in distinct columns, but in the form below it returns in rows. I tried to use LEFT JOIN but the syntax did not work.

select u.nome_completo AS NOME1 from usuarios u where u.cracha = 5357 UNION
select u.nome_completo AS NOME2 from usuarios u where u.cracha = 9999

Return from this query:

Desiredreturn:

    
asked by anonymous 27.04.2016 / 15:11

1 answer

2

Making the Pivot "on hand"

select max(nome1) nome1 , max(nome2) nome2
from
(
select u.nome_completo AS NOME1 , '' as nome2 from usuarios u where u.cracha = 5357 
UNION
select '' as nome1 , u.nome_completo AS NOME2 from usuarios u where u.cracha = 9999
) virtual
    
27.04.2016 / 20:18