Select to join two Father and Son tables one below the other

Asked

Viewed 101 times

0

inserir a descrição da imagem aqui

I would like to know how to get the result according to the image, I have a column with id that links the father and son records, I know that the join joins the tables side by side, however, needed to join below.

1 answer

1

Use the UNION operator:

SELECT * FROM
(
    SELECT chave, Data_Venda, Qtde_Produto, Valor_Produto FROM Tabela_Pai
    UNION
    SELECT chave, Data_Venda, Qtde_Produto, Valor_Produto FROM Tabela_Filho
) temp
ORDER BY chave;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.