0

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 posteds of posts 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?

1 Answer 1

2

Add a ; to the end of your update statement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.