Hi folks,
i have two tables.
BoardPosts
BoardPostId INT PK
ModifiedOn DATETIME NULLABLE
BoardComments
BoardCommentId INT PK
BoardPostId INT
CreatedOn DATETIME
A board post has zero to many comments.
I wish to set the ModifiedOn
field to be the most recent comment date, if the board has a comment. Otherwise, just leave it null.
How do i do this, using TSql ?
something like ...
UPDATE BoardPosts
SET ModifiedOn = CreatedOn
SELECT TOP(1) CreatedOn
FROM BoardPosts a INNER JOIN BoardComments b ON a.BoardPostId = b.BoardPostId
???