In Ms Access, I’m trying to write a SQL query that answers a question like:
Return all player IDs on all teams in a list of football players where at least one member of the team is injured.
I’m new to SQL. I’ve tried something like
SELECT pid FROM players WHERE team_id IN
(SELECT team_id FROM players WHERE injury = 'yes')
Access won’t accept this IN. Is there a simple way to do this? I’d rather run thus as one query, instead of creating separate queries, so I can change it easily as necessary.
I find it hard to believe that it doesn’t support
IN, nevertheless you can do it using a join:I used
distinctin case there’s multiple injured players on the one team, which would result in the players from that team being returned multiple times