How to delete records with the same ID from multiple tables in mysql

Source: Internet
Author: User

 


The question was answered by Baidu five years ago. When I first saw this question, I had just been working for 21 days. Then, based on my own experience and Temporary Operation tests, I made a correct answer:

 

But soon I was denied. I guess the main reason is that the last sentence I said is too absolute, but because I believe in myself too much, and there are a lot of reasons to support it, I have not studied it in depth.

Recently, some netizens commented on my answer. I started to check Baidu and found that MySQL and later versions can delete data from multiple tables using one delete operation.
It seems that I am indeed mistaken, I can only say sorry, fortunately, the landlord did not select my answer, or else it would be a great sin.

Summary:

You can delete multiple tables in MySql4.0 or later versions.Delete t1, t2 from t1.refid = t2.id

SQL Server is not supported until 2008

Oracle is almost useless and uncertain. What I found online is that it 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.

You can delete data in multiple tables in one row.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.