Solved

MySQL - DISTINCT values on a multi table select...

Posted on 2013-05-21
3
371 Views
Last Modified: 2013-05-24
Hi,  I should know this one, but have always side stepped the need to find out before..

I am doing a select, joining two tables, but I want the results to be DISTINCT by HOUSEHOLD_ID, while I still want the rest of the data to test on.

With 5 rows in the table, this:

SELECT DISTINCT * from GAMES_PLAYED GP, HOUSEHOLD H where H.HOUSEHOLD_ID=GP.HOUSEHOLD_ID AND GP.CREATED_TIMESTAMP >= '2013-05-20 16:00:00' AND GP.CREATED_TIMESTAMP < '2013-05-21 16:00:00' ORDER BY SCORE1_VALUE DESC LIMIT 50

Gives me:
15 201 32132
15 203 2322
15 204 832
2 202 736
7 200 0

But I need it to be distinct on the first value and give me:
15 201 32132
2 202 736
7 200 0

Top points for a quick answer.

Thanks,

Cris.

PS. Where is MySQL in the question topics?
0
Comment
Question by:CrisThompsonUK
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:CrisThompsonUK
Comment Utility
BOOM.  Sorted.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points and good luck with your project, ~Ray
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now