Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    35

    Question Unanswered: Group By and MAX Problem

    --------------------------------------------------------------------------------

    I am trying to get the last occurance of a display name in a login user log database. Basically I have a table that looks like this:

    id user fname lname
    -----------------------------------
    1 jdoe Jane Doe
    2 jdoe John Doe
    3 jdoe Fred Flinstone


    I run the MySQL query: SELECT name, max(id) as max_id, user FROM `logins` GROUP BY user

    I get back:
    id user fname lname
    -----------------------------------
    3 jdoe Jane Doe


    I actually want:
    id user fname lname
    -----------------------------------
    3 jdoe Fred Flinstone


    Any that can help it would be greatly Appreciated!!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •