Created
May 15, 2019 13:37
-
-
Save airtonGit/c0f4b830745a29f0e6502e22ba29a462 to your computer and use it in GitHub Desktop.
SQL inserir em tabela usando select em outra como origem das linhas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO tabelaDestino | |
SELECT null, campo1, campo2, CURRENT_TIMESTAMP, alias1.campoA | |
FROM tabelaOrigem | |
INNER JOIN tabelaRelacionada1 alias1 ON alias1.id = alias2.fk_id | |
WHERE | |
alias1.active = true | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cenário usado: Adicionar 1 linhas para cada linha existente em tabela relacionada(tabelaOrigem) 1 pra 1