2

我正在尝试创建一个触发器来更新两个独立数据库之间的数量。此查询成功运行,但是当我在 mysql 中显示触发器时,它会显示一个空集。任何帮助将非常感激。

delimiter $$ CREATE TRIGGER `quantity_to_clb` AFTER UPDATE ON product 
FOR EACH ROW BEGIN UPDATE cl_boutique.product AS clb 
LEFT JOIN cherrylane.product AS cl 
ON clb.model = cl.code SET clb.quantity = cl.available
 WHERE clb.model = cl.code
 END $$ 
delimiter ;
4

1 回答 1

2

那是因为您的代码有两个语法错误:

delimiter $$ --delimiter statements need to be on separate lines
CREATE TRIGGER `quantity_to_clb` AFTER UPDATE ON product 
FOR EACH ROW BEGIN 
  UPDATE cl_boutique.product AS clb 
  LEFT JOIN cherrylane.product AS cl 
  ON clb.model = cl.code SET clb.quantity = cl.available
   WHERE clb.model = cl.code; -- ; was needed here
END $$ 
delimiter ;
于 2013-02-27T19:15:06.127 回答