cooldude832 Posted November 14, 2008 Share Posted November 14, 2008 Title basically says it LOG TABLE LogID Date_Entered UserID UnderwriterID Message I want to get 1 row for each UserID that is the row of the max Date_Entered (or max LogID as they are the same) Quote Link to comment https://forums.phpfreaks.com/topic/132726-selecting-the-last-entry-in-a-log-table-for-each-user/ Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 SELECT UserID,MAX(Date_Entered) as MaxDate FROM LogTable GROUP BY UserID Quote Link to comment https://forums.phpfreaks.com/topic/132726-selecting-the-last-entry-in-a-log-table-for-each-user/#findComment-690239 Share on other sites More sharing options...
Barand Posted November 14, 2008 Share Posted November 14, 2008 try SELECT l.LogID, l.Date_Entered, l.UserID, l.UnderwriterID, l.Message FROM log l INNER JOIN ( SELECT logID, MAX(Date_Entered) as Date_Entered FROM log GROUP BY logID ) as X USING (logID, Date_Entered) Quote Link to comment https://forums.phpfreaks.com/topic/132726-selecting-the-last-entry-in-a-log-table-for-each-user/#findComment-690373 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.