Suppose you have a database schema with tournaments related to games. There can be many games in a tournament.
I am trying to join tournaments for games and only retreat from tournaments with all games in the future.
SELECT DISTINCT tournaments.*
FROM tournaments
INNER JOIN games ON tournaments.game_id = games.id
WHERE games.event_date >= NOW();
There are a few more tables that I join, but I simplified this for the sake of this example.
My query returns results when not all games in the tournament in the future.
I also tried moving the condition to the connection:
SELECT DISTINCT tournaments.*
FROM tournaments
INNER JOIN games ON (tournaments.game_id = games.id AND games.event_date >= NOW())
but I get the same result.
How can I make sure that all tournaments won will have games in the future - that is, a mandatory condition for all lines related to?
Thank!
shedd source
share