【发布时间】:2010-02-15 00:28:17
【问题描述】:
我使用触发器插入一行,并希望在后续查询中使用最后创建的 id。
我该怎么做?
代码如下:
BEGIN
IF (NEW.counter >= 100) THEN
INSERT INTO tagCategories (name, counter) VALUES ('unnamed', NEW.counter);
// here i want to have access to the above inserted id
UPDATE tagCategories2tagPairs SET tagCategoryId = <<ID_HERE>> WHERE tagPairId = OLD.id
END IF;
END
【问题讨论】: