How to delete from multiple tables in MySQL?

后端 未结 7 845
温柔的废话
温柔的废话 2020-11-22 07:57

I am trying to delete from a few tables at once. I\'ve done a bit of research, and came up with this

DELETE FROM `pets` p,
            `pets_activities` pa
          


        
相关标签:
7条回答
  • 2020-11-22 08:58

    Use this

    DELETE FROM `articles`, `comments` 
    USING `articles`,`comments` 
    WHERE `comments`.`article_id` = `articles`.`id` AND `articles`.`id` = 4
    

    or

    DELETE `articles`, `comments` 
    FROM `articles`, `comments` 
    WHERE `comments`.`article_id` = `articles`.`id` AND `articles`.`id` = 4
    
    0 讨论(0)
提交回复
热议问题