I have two tables: COMMENT and COMMENTHISTORY
Now I need to select cells from both tables, for example:
SELECT c.Id, c.Userid, ch.Text, ch.Timestamp FROM COMMENT c, COMMENTHISTORY ch WHERE ch.CommentId = c.Id ORDER BY ch.Timestamp DESC
It works great. The only problem is that COMMENTHISTORY has several lines for each COMMENT , so SELECT ends up getting several lines for each comment.
I need to get one line for each comment. A line where ch.Text and ch.Timestamp correspond to the last corresponding COMMENTHISTORY line.
Any ideas on how to do this?
Thanks.
source share