Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-21
3
Medium Priority
?
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

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

Author Closing Comment

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

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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