This is a discussion on Selecting the newest file from a user... within the PHP Language forums, part of the PHP Programming Forums category; Ok, I haven't passed MYSQL 101 yet and something I thought would be a piece of cake has be ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Ok, I haven't passed MYSQL 101 yet and something I thought would be a
piece of cake has be stumped (it is almost 1a.m. thought ;)). MYSQL: 3.23 TABLE: file_id member_id file_name file_upload_datetime (datetime) catagory I want to find the 5 most recent files uploaded but only one per user... I tried SELECT member_id, file_name, MAX(file_upload_datetime) AS newest WHERE catagory = 1 GROUP BY member_id ORDER BY newest DESC LIMIT 3 and a few other variations but can only get "close." :( FYI: I didn't execute the query above, just showing the logic so if there are typos please ignore. ;) TIA for any insights offered! |
|
|||
|
On Tue, 04 May 2004 00:56:21 -0700, Bill H <maylar69@hot----.com>
wrote: Oops, sorry... wrong group. ;) >Ok, I haven't passed MYSQL 101 yet and something I thought would be a >piece of cake has be stumped (it is almost 1a.m. thought ;)). > >MYSQL: 3.23 > >TABLE: > >file_id >member_id >file_name >file_upload_datetime (datetime) >catagory > >I want to find the 5 most recent files uploaded but only one per >user... > >I tried > >SELECT >member_id, >file_name, >MAX(file_upload_datetime) AS newest > >WHERE >catagory = 1 > >GROUP BY >member_id > >ORDER BY >newest DESC > >LIMIT 3 > >and a few other variations but can only get "close." :( FYI: I didn't >execute the query above, just showing the logic so if there are typos >please ignore. ;) > >TIA for any insights offered! > > > > Oops, sorry... wrong group. ;) |