I am lookign for the correct SQL code to join 2 tables and show only the last record of the details table.
I have a DB with 2 tables,
Deals Deal
Try this:
CREATE VIEW DealsWithLastComment AS SELECT D.*, DC.* FROM Deals D INNER JOIN DealComments DC ON D.DealID = DC.DealID GROUP BY D.DealID, DC.CommentTime HAVING DC.CommentTime = MAX(DC.CommentTime)