I’ve got two tables, one with games and one with participants.
A game can have multiple participants. Now I need to search if a game is already inserted. I made a query with an inner join.
SELECT game.gameId
FROM game
INNER JOIN participants
WHERE game.gameId = participants.gameId
AND participants.name = 'Team1'
AND participants.name = 'Team2'
This isn’t working the way I expected, is there a way to check if there is a match between teams 1 and 2 in one query?
Thanks!
edit
tablelayout:
**game**
PK gameId
date
**participants**
PK id
FK gameId
name
type //home or visiting
You’re not trying to relate game to participants, but participants to itself.