jameslagan
Registered User.
- Local time
- Today, 11:24
- Joined
- Jan 13, 2012
- Messages
- 10
I have a table with people that have disease X - tbl:[Disease X]that are being matched to disease-free "controls" tbl:[Controls] ensuring that they match gender and location.
Currently I have an inner join that looks something like this:
SELECT blah blah blah
FROM [Controls] INNER JOIN [Disease X] ON ([Controls].Location = [Disease X].Location) AND ([Controls].Gender = [Disease X].Gender);
Easy!
This returns multiple controls for each disease X. Naturally, some of which are actually the same control.
For instance, [Disease X] ID 1 might match with [Controls] ID 3, but [Disease X] ID 4 might also match with [Controls ID] 3 (as they are the same gender and location).
Is there any way of ensuring that once a control has been matched once with a Disease X - they are then no longer allowed to match with another Disease X?
Perhaps using DISTINCT, UNIQUE or DISTINCTROW might be an option but I just don't know how to use these.
Many thanks for any help on this subject,
Cheers,
James
Currently I have an inner join that looks something like this:
SELECT blah blah blah
FROM [Controls] INNER JOIN [Disease X] ON ([Controls].Location = [Disease X].Location) AND ([Controls].Gender = [Disease X].Gender);
Easy!
This returns multiple controls for each disease X. Naturally, some of which are actually the same control.
For instance, [Disease X] ID 1 might match with [Controls] ID 3, but [Disease X] ID 4 might also match with [Controls ID] 3 (as they are the same gender and location).
Is there any way of ensuring that once a control has been matched once with a Disease X - they are then no longer allowed to match with another Disease X?
Perhaps using DISTINCT, UNIQUE or DISTINCTROW might be an option but I just don't know how to use these.
Many thanks for any help on this subject,
Cheers,
James