您好,我在删除后创建了触发器,仍然存在错误:“ where子句”中的未知列“ OLD.merchant_id”
DELETE FROM on_size WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_category WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_item WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_merchant_user WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_offers WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_rating WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_review WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_voucher WHERE merchant_id=OLD.merchant_id;
DELETE FROM on_voucher_new WHERE merchant_id=OLD.merchant_id;
DELETE ord,ord_da,ord_det,ord_his,ord_sms
FROM on_order ord
JOIN on_order_delivery_address ord_da ON ord.order_id=ord_da.order_id
JOIN on_order_details ord_det ON ord.order_id=ord_det.order_id
JOIN on_order_history ord_his ON ord.order_id=ord_his.order_id
JOIN on_order_sms ord_sms ON ord.order_id=ord_sms.order_id
WHERE ord.merchant_id=OLD.merchant_id;
我可以在触发器中删除多个表吗?
只有on_order可以与商人ID一起标识,其他表则不能。
谢谢。
最佳答案
缺少BEGIN和END。
声明之后一切正常。
关于mysql - 从多个表删除后的MySQL触发器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40362062/