Selecting the newest file from a user...

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-04-2004
Bill H
 
Posts: n/a
Default Selecting the newest file from a user...

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!





Reply With Quote
  #2 (permalink)  
Old 05-04-2004
Bill H
 
Posts: n/a
Default Re: Selecting the newest file from a user...

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. ;)

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:25 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0