How to delete from multiple tables in MySQL?

后端 未结 7 851
温柔的废话
温柔的废话 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:57

    I don't have a mysql database to test on at the moment, but have you tried specifying what to delete prior to the from clause? For example:

    DELETE p, pa FROM `pets` p,
            `pets_activities` pa
      WHERE p.`order` > :order
        AND p.`pet_id` = :pet_id
        AND pa.`id` = p.`pet_id`
    

    I think the syntax you used is limited to newer versions of mysql.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题