0

您好我正在尝试创建一个触发器,该触发器将 1 添加到保存 id 代码的帮助表中的插入 id 的数量。这是我的 2 张桌子。

     Animal
   ----------
   AnimalId
   Breedcode

   Breed_codes
  ------------
   Breedcode
   breed
   Quantity

     CREATE TRIGGER `updater` AFTER INSERT ON `Animal`
     FOR EACH ROW UPDATE breed_codes
     SET Quantity = Quantity + 1
     WHERE Breedcode = Animal.Breedcode

但是它指出找不到动物品种代码。谁能帮我修理我的触发器。谢谢

4

1 回答 1

0

In your UPDATE query you can use:

  1. Column names from the table(s) you are updating,
  2. Column names from the table you define trigger for with NEW.column (insert and update triggers) or OLD.column (update and delete triggers).

In your case instead of Animal.Breedcode you should use New.Breedcode.

于 2013-04-22T04:42:41.513 回答