CrisThompsonUK
asked on
MySQL - DISTINCT values on a multi table select...
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.HOUSEHOL D_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?
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.HOUSEHOL
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points and good luck with your project, ~Ray
ASKER