0

I have table question

id        int
answers   int

With every insert, delete call on this table I want to update answers column. I want to use trigger on this. I don't know how I can read question.id within trigger for insert, delete.

Any help appreciated.

Thanks.

4

2 回答 2

1

在插入后发生的触发器中,您可以从inserted表中选择以获取任何插入行的 id。同样对于删除,您可以从deleted表中选择。

于 2012-07-22T22:56:33.687 回答
0

在 BEFORE/AFTER INSERT 触发器中,您可以将 OLD 和 NEW 与“id”(OLD.id/NEW.id)和“answer”(OLD.answer/NEW.answer)列一起使用。您将能够获得每列的旧值和新值。同样,在 AFTER DELETE 触发器中,您可以获得 OLD.id 和 OLD.answer,这反过来将给出已删除行的值

于 2012-07-27T11:51:08.767 回答