How to exclude a data from one or more tables

Asked

Viewed 31 times

0

fazerI have an id that appears in several tables but, I need to delete it in the main page and delete it in all other tables as well. ex :

DELETE FROM admissao_dominio.*,  admissao.*,  bancarios.*,  boas_vindas.*,  documentacao.*,  exame_admissional.*,  gestao.*,  interno.*,  parametros_captacao.*,  propostas_contratacoes.*,  sede.*,  suporte_interno.*,  tipo.*,  usuario_atv.*,  vencimentos.*,  vias_documentos_funcionarios
WHERE EMAIL = '{$_GET['id']}'";

It’s wrong but it’s like something like this that I need.

  • Do these tables have relationships with each other? If they relate, you can delete using Inner Join.

  • yes they are all linked by the id_user, or by some other call, type is a user registration and the data appear in different places, but when I click delete I need to delete from all tables

  • Take a look at this here, is very likely to solve your problem.

1 answer

1


To delete more than one table, you need join together all of them.

DELETE admissao_dominio,  admissao,  bancarios/*,  boas_vindas,  documentacao,  exame_admissional,  gestao, interno,  parametros_captacao,  propostas_contratacoes,  sede,  suporte_interno,  tipo,  usuario_atv,  vencimentos, vias_documentos_funcionarios */
FROM admissao_dominio
JOIN admissao ON admissao.ID = admissao_dominio.ADIMISSAO_ID
JOIT bancarios ON bancarios.ADMISSAO_ID = admissao.ID
/* join das demais tabelas */
WHERE EMAIL = '{$_GET['id']}'";

Try it like this, doing Join among all tables, this should delete correctly!

Browser other questions tagged

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