MySQL performs multi-table delete

For example, if you delete an article (table article), its comments (another table comment) use articleId as a foreign key. When deleting an article (assuming the id is 1, and the comment is to be deleted at the same time, the actual id is naturally passed through parameters) ), you can use the following statement: 

delete a,c from article a,comment c where a.id = 1 and c.articleId = 1;  

 

Reprinted from: http://caiceclb.iteye.com/blog/297660

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326914257&siteId=291194637