Skip to content

Instantly share code, notes, and snippets.

@dodopok
Created October 4, 2013 13:01
Show Gist options
  • Save dodopok/6825544 to your computer and use it in GitHub Desktop.
Save dodopok/6825544 to your computer and use it in GitHub Desktop.
Copia registro que não existe em outra tabela para outra tabela
insert into almoxarifado_produtos (produto_id, almoxarifado_id, quantidade, created, modified, group_id, user_id)
SELECT id, almoxarifado_id, 0, '2013-10-04 10:00:00', '2013-10-04 10:00:00', group_id, user_id FROM `produtos` WHERE NOT EXISTS(SELECT id FROM almoxarifado_produtos WHERE produto_id = produtos.id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment