Find records in one table and not in another

Johnny C

Registered User.
Local time
Today, 10:10
Joined
Feb 17, 2014
Messages
19
I've got 2 tables, same structure, one [T-temp-Target] holds number of training units split by module a trainee needs to finish the course, the other [T-temp-Actual] holds what they've completed so far.

Both tables have structure
TRAINEEID
MODCODE
CountOfUnits

I'm trying to find the modules that they've not done yet so I can add up the units for them, only modules that have been started are recorded in the table of what they've done [T-temp-Actual], modules they haven't started yet aren't included in it. Here's the SQL

Code:
SELECT 
     [T-temp-Target].TRAINEEID, 
     [T-temp-Target].MODCODE, 
     [T-temp-Actual].MODCODE
FROM [T-temp-Actual] INNER JOIN [T-temp-Target] ON 
     ([T-temp-Actual].TRAINEEID = [T-temp-Target].TRAINEEID) AND
     ([T-temp-Actual].MODCODE = [T-temp-Target].MODCODE) 
WHERE ((([T-temp-Actual].MODCODE) Is Null));

but it's just coming up blank, there should be a few hundred thousand records.

What am I doing wrong?
 
Don't answer, I figured out i needed left joins not inner joins :)
 
Actually, you need one table for all of this information. You shouldn't create new tables for data that can be contained in a field.

All of this data should be in one table that has one more field that designates if the course was completed or not.
 

Users who are viewing this thread

Back
Top Bottom