This is what I have so far:
I know I'm using an INSERT here but can't work out how to use the UPDATE statement instead...
CREATE TRIGGER AvgRatingTrigger ON dbo.Post AFTER INSERT AS INSERT INTO dbo.Place (AvgRating) /*Possibly should be UPDATE?*/ SELECT AVG(Rating) FROM dbo.Post
I would think I need something like WHERE Post.PlaceID = Post.PlaceID after the SELECT statement above but have tried that and it doesn't work.
If I do add that in I get this error: "The multi-part identifier "dbo.Post.Rating" could not be bound."
These are the tables:
Post table: PostID - PK - uniqueIdentifier UserID - FK - uniqueIdentifier PlaceID - FK - int Review - text Rating - int ReviewTime - datetime Place table: PlaceID - PK - int CategoryID - FK - int Country - varchar City - varchar Place - varchar AvgRating - int