从多个表中删除后触发Mysql

时间:2016-11-01 14:25:05

标签: mysql triggers multiple-tables

你好我在删除后创建触发器并且仍然有错误:'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可以用merchant_id识别,其他表格没有这个。

谢谢。

1 个答案:

答案 0 :(得分:0)

缺少BEGIN和END。 声明完全没问题。