Having a bit of trouble with a join statement in some SQL I'm working on. Wondered if there were any smart people out there who would be able to help me with my problem!
I'm trying to JOIN 3 tables: tblMember, tblResult and tblPoint
tblMember - Containing user info such as names and emails. tblResult - Containing details of members and the races they have signed up for, as long as details of their finish positions and times they completed the race in. tblPoint - containing a set of points relating to what position a person finishes in a race, eg 1st place gets 10 points, 2nd gets 8... there are no points assigned if a person finishes 6th or below.
I want the query to return tblResult.ResultID, tblMember.MemberName, tblResult.PersonalTime, tblResult.FinishPosition, tblPoint.Points. BUT I want it to return all of these fields even if FinishPosition is empty and there are no points assigned.
I have almost solved the problem by using this SQL below:
SELECT DISTINCT tblResult.ResultID, tblMember.MemberName, tblResult.PersonalTime,
tblResult.FinishPosition, tblPoint.Points
FROM (tblMember INNER JOIN tblResult ON tblMember.MemberID = tblResult.MemberID) LEFT
JOIN tblPoint ON tblResult.FinishPosition = tblPoint.Position;
HOWEVER this doesn't quite work. When my query returns the results, someone who has already been assigned a position, say 2nd place, is returned multiple times with points for 1st place assigned the first time, and then the points for 2nd place assigned the second time!
This has got to be a JOIN issue... But I can't see how to rectify it! I have already tried using IIF and ISNULL but I don't think it was the right thing to use.
I'm using MS Access which appears not to support LEFT OUTER JOIN, RIGHT OUTER JOIN or FULL JOIN.
Can anyone help? Thanks for reading this. :)
EDIT: [tblPoint] contains fields (PointID, RaceTypeID, Points, Position). There are 5 rows for each race type. PointID is the primary key and the table could look like:
Point ID - 1, RaceTypeID - 1, Points - 10, Position - 1
Point ID - 2, RaceTypeID - 1, Points - 6, Position - 2
Point ID - 3, RaceTypeID - 1, Points - 3, Position - 3
Point ID - 4, RaceTypeID - 1, Points - 2, Position - 4
Point ID - 5, RaceTypeID - 1, Points - 1, Position - 5.
This means that for race type 1, whoever comes 1st gets 10 points, 2nd gets 6 points and so on. This table can support different race types, each race type with its own point system.
A member can appear any amount of times in tblResult, once a member has 'signed up' to participate they appear in tblResult, with no finish position or personal time assigned.