【发布时间】:2012-09-08 06:48:08
【问题描述】:
我写了一个类似这样的触发器:
CREATE TRIGGER `update_after_itemPresent` AFTER INSERT ON `bus_repair`
FOR EACH ROW begin
IF NEW.unit <> `item_present`.`unit` THEN
update item_present
set unit = unit-new.unit
where item_present.item_group_id = new.item_group_id;
END IF;
end
但是当我在bus_repair 表中插入新行时,会出现以下错误:
字段列表中存在未知表项
知道如何解决这个问题吗?
【问题讨论】:
-
你确定
unit-new不应该是unit_new吗?你能展示item_present表的结构吗? -
兄弟,unit(minus)new.unit.....unit 来自 item_present 表,new.unit 来自 bus_repair 表....现在我已经检查了没有任何 if 语句的触发器,它工作正常。但是当我包含 if 语句时,它会显示错误。我确定问题出在 if 部分。
标签: mysql sql sql-update