Solved

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

Posted on 2013-05-21
3
372 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
ID: 39184610
0
 

Author Closing Comment

by:CrisThompsonUK
ID: 39186794
BOOM.  Sorted.
0
 
LVL 108

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 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

20 Experts available now in Live!

Get 1:1 Help Now