简体   繁体   English

PHP MySQL代码从具有相同ID的多个表中删除数据

[英]php mysql code to delete data from multiple table having same id

I have a form from where Information is entered into multiple database having same id, if by mistake wrong data is entered, I want to delete that from all tables. 我有一个表格,信息从该表格输入到具有相同ID的多个数据库中,如果错误地输入了错误的数据,我想从所有表中删除它。

How and what should I do to delete from all information related to that id from all tables. 我应该如何以及从所有表中删除与该ID相关的所有信息。

You can do multiple table deletes:- 您可以删除多个表格:

http://dev.mysql.com/doc/refman/5.0/en/delete.html http://dev.mysql.com/doc/refman/5.0/en/delete.html

For example say you had 4 tables and want to delete all the records in 3 of them that relate to the 1st table:- 例如,假设您有4个表,并且要删除其中3个与第一个表相关的所有记录:-

DELETE Table1, Table2, Table3
FROM Table0
INNER JOIN Table1
ON Table0.Id = Table1.ParentId
INNER JOIN Table2
ON Table0.Id = Table2.ParentId
INNER JOIN Table3
ON Table0.Id = Table3.ParentId
WHERE Table0.Id = 1

Of course you could also delete from the first table (Table0) as well. 当然,您也可以从第一个表(Table0)中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM