TABLE: pages
pageId | name
 1     | Home
 2     | About Us
 3     | Contact Us
Then i have stats stored:
TABLE: hits
hid | created    | assignId
01  | 1000000001 | 1
02  | 1000000002 | 1
03  | 1000000003 | 3
So basically, "Home" was opened twice, "About us" never, and "Contact us" once. Also notice that Contact us was most recently accessed.
I need a query that returns this:
pageId | name         | lastAccessDate
 1     | Home         | 1000000002   --> NB: Notice that it takes the higher one
 2     | About Us     | null
 3     | Conta开发者_开发技巧ct Us   | 1000000003
Anybody know how to do this?
This should work
SELECT p.pageId, p.name, MAX(s.created) FROM pages p LEFT JOIN stats s ON p.pageId=s.assignId GROUP BY p.pageId ORDER BY pageid ASC
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论