Bluehost.com Web Hosting $6.95

Make GROUP BY select entries i want

This is a discussion on Make GROUP BY select entries i want within the MySQL Database forums, part of the Database Forums category; Hi Is there a way to tell group by to group by lets say user_id and to choice the entry ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-05-2006
Ralph
 
Posts: n/a
Default Make GROUP BY select entries i want

Hi

Is there a way to tell group by to group by lets say user_id and to
choice the entry where login_time is most recent?

Thank you
Ralph
Reply With Quote
  #2 (permalink)  
Old 11-06-2006
Bill Karwin
 
Posts: n/a
Default Re: Make GROUP BY select entries i want

Ralph wrote:
> Is there a way to tell group by to group by lets say user_id and to
> choice the entry where login_time is most recent?


Maybe you need to run GROUP BY on your newsgroup posts, too. ;-)

No, there's no way to tell GROUP BY to resolve the ambiguity for you.

Here's a solution for the question you asked:

SELECT t1.*
FROM tablex AS t1 LEFT JOIN tablex AS t2
ON t1.user_id = t2.user_id AND t1.login_time < t2.login_time
WHERE t2.login_time IS NULL

Regards,
Bill K.

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 03:22 PM.


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