Hi. I have a table called posts
having an INT
field posted
and a table domains
having field posted
too, this one is supposed to be the sum of a posted
s of post
s belonging to a certain domain
. Whether the post belongs to a domain is determined by a foreign domain_id
in the table posts
which links to the id
in domains
. I'm trying to create a trigger that would update the posted
of a domain every time the posted
is changed for any of its posts. Here's what I was trying:
CREATE TRIGGER [update_posted]
AFTER UPDATE OF [posted]
ON posts
BEGIN
UPDATE domains SET posted = posted + NEW.posted - OLD.posted WHERE id = NEW.domain_id
END
which complains about bad syntax near END
. What's the problem?