Mysql 从多个表中删除后触发
Mysql trigger after delete from multiple tables
您好,我在删除后创建了触发器,但仍然出现错误:Unknown column 'OLD.merchant_id' in 'where clause'
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识别其他表没有这个。
谢谢。
缺少 BEGIN 和 END。
声明后就ok了
您好,我在删除后创建了触发器,但仍然出现错误:Unknown column 'OLD.merchant_id' in 'where clause'
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识别其他表没有这个。
谢谢。
缺少 BEGIN 和 END。 声明后就ok了