If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Group By and MAX Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-03-05, 21:41
pebkac pebkac is offline
Registered User
 
Join Date: Jan 2004
Posts: 35
Question 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!!
Reply With Quote
  #2 (permalink)  
Old 10-03-05, 23:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
see group by help?

please don't cross-post

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On