I want a trigger to DELETE from 2 tables in MySQL

后端 未结 5 1684
渐次进展
渐次进展 2020-12-10 13:16

I have 3 MySQL tables (food, apple, and orange).

I want to delete rows from:

apple(idapple, iduser, name) 
ora         


        
5条回答
  •  醉话见心
    2020-12-10 13:54

    CREATE TRIGGER `food_before_delete`     
    AFTER DELETE ON `food`     
    FOR EACH ROW     
    begin
      DELETE FROM apple
      WHERE apple.iduser=NEW.iduser;
    
      DELETE FROM orange
      WHERE orange.iduser=NEW.iduser;
    end
    

    The delete statements may require OLD.iduser and not support NEW.iduser. Check your manual.

提交回复
热议问题