Solved

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

Posted on 2013-05-21
3
374 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 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39184610
0
 

Author Closing Comment

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

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 count occurrences of each item in an array.

838 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