Divide result of a query with many fields in 2 lines

0

I have a table with these fields:

Usuario1    Nif1    Nombre1     Telefono1     Usuario2    Nif2     Nombre2     Telefono2

1          213    Pepe         123456       2           546      Juan        89173
3          456    Miguel       434342       4           534      Pablo       43434

When doing a SELECT I would be interested in the last 3 fields of the Table corresponding to another user to jump to another line. The result should look like this:

Usuario    Nif   Nombre       Telefono

1          213   Pepe         123456
2          546   Juan         89173
3          456   Miguel       434342
4          534   Pablo        43434
    
asked by Popularfan 21.09.2018 в 16:54
source

1 answer

1

Similar to the following:

Select
    Usuario1 as Usuario, 
    Nif1 as NIf,
    Nombre1 as Nombre,
    Telefono1 as Telefono
from mitabla
union
Select
    Usuario2 as Usuario,
    Nif2 as Nif,
    Nombre2 as Nombre
    Telefono2 as Telefono
from mitabla
order by Usuario;
    
answered by 21.09.2018 / 17:01
source