[Solved] How do I find which records in a table have no corresponding record in another table [closed]


How do you represent the linkage of a person to a team. Do you use a teamID field in person? If so, what do you do when a person is not on a team? Keep it null?

select * from person where teamID is null

Set it to -1?

select * from person where teamID == -1

Maybe you have a person_team cross table (which would be odd because you said that a person could only be on one team). If so

SELECT * FROM person LEFT OUTER JOIN person_team
 ON (person.id = person_team.personID)
 WHERE person_team.personID IS NULL    

Or if you have something else — tell us.

2

solved How do I find which records in a table have no corresponding record in another table [closed]