• notice
  • Congratulations on the launch of the Sought Tech site

Multi-tables in MySQL delete the same records of the same record


The question originated from a Baidu who knew the answer 5 years ago.When I first saw this question, I had just been at work for 21 days , Then based on his little experience and temporary operation test, he made the answer that he thought was correct at the time:


But it was quickly rejected.I guess the main reason is that the last sentence I said was too absolute, but because I was too Believe in myself, and there are a lot of reasons to support it, so I didn't study it in depth.

Recently, some netizens commented on this answer of mine.I just started to check Baidu and found that the version of Mysql4.0 and above can delete the data of multiple tables with a single delete.
It seems that I'm really misleading people, so I can only say sorry.Fortunately, the host didn't choose my answer, or the crime was too serious.

Finally, let’s summarize:

MySql4.0 and above support delete multiple tables to delete delete t1,t2 from t1.refid=t2.id

SqlServer does not support until 2008

Oracle almost doesn’t use it, I’m not sure, what I found online does not support delete to delete data from multiple tables

For databases that do not support delete to delete multiple tables, you can do some preliminary work, such as triggers and foreign keys.

Can realize "one delete" delete data in multiple tables.


Technical otaku

Sought technology together

Related Topic


Leave a Reply