Selecting the newest file from a user...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill H

    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_dat etime (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!





  • Bill H

    #2
    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. ;)
    [color=blue]
    >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_da tetime (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_uploa d_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!
    >
    >
    >
    >[/color]

    Oops, sorry... wrong group. ;)

    Comment

    Working...