Getting Duplicate SQL Return

The following query is giving me double results.  How can I modify it to not do that?

SELECT ir.ParticipantID FROM IndResults ir INNER JOIN Participant p ON ir.ParticipantID = p.ParticipantID INNER JOIN PartRace pr ON ir.RaceID = pr.RaceID WHERE pr.RaceID = 386 AND ir.RaceID = 386  AND p.Gender = 'F' AND pr.Age >= 55 AND pr.Age <= 59 ORDER BY ir.EventPl

Thank you!
Bob SchneiderCo-OwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dany BalianCTOCommented:
add distinct

SELECT distinct ir.ParticipantID FROM IndResults ir INNER JOIN Participant p ON ir.ParticipantID = p.ParticipantID INNER JOIN PartRace pr ON ir.RaceID = pr.RaceID WHERE pr.RaceID = 386 AND ir.RaceID = 386  AND p.Gender = 'F' AND pr.Age >= 55 AND pr.Age <= 59 ORDER BY ir.EventPl

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
why do you order this distinct list of participants by results?

do you now intend to use that list as a cursor?
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

PortletPaulfreelancerCommented:
Apologies to all participants, I know it's closed but the answer to this will help on another.

@BobbaBuoy,

Are you SURE that's a good query?
I think there is a join condition missing (see line 8 below). PLEASE try this, and please let me know if there are still duplicates
SELECT
      ir.ParticipantID
FROM IndResults ir
      INNER JOIN Participant p
                  ON ir.ParticipantID = p.ParticipantID
      INNER JOIN PartRace pr
                  ON ir.RaceID = pr.RaceID
                  AND ir.ParticipantID = pr.ParticipantID
WHERE ir.RaceID = 386
      AND p.Gender = 'F'
      AND pr.Age >= 55
      AND pr.Age <= 59
ORDER BY
      ir.EventPl
;

Open in new window

0
Bob SchneiderCo-OwnerAuthor Commented:
Very helpful.  Thanks all!!!
0
PortletPaulfreelancerCommented:
did it remove the duplicates?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.