Suppose you have 3 tables:
Players:
player_id, player_name, etc.
Teams:
team_id, team_name, ...
players_in_teams:
team_id, player_id, ...
You simply query your database:
select player_id from players
minus
select player_id from players_in_teams
Of course, you may want to complexify things by adding in players_in_teams a date range from ... until (i.e. player x has been in team a from date i1 to date j1 , in team b from date i1 to date j2, etc.
Then you have to take care of some conditions:
- dont select players who do not have an until_date (as they obviously are still in a team)
- dont select players that have a until_date in the future
select player_id from players
minus
select player_id from players_in_teams
where max(until_date) < sysdate
You can also add a condition to include players who are not in a team right now, but who will be next year/month/week..
I hope I did not overlook some condition, but I think you see what I mean: I leave the details up to you.
Have a nice day,
JJ Mouris