我有以下sql:
SELECT tournaments_blg.tournament_id_blg
FROM matches_blg LEFT JOIN tournaments_blg ON tournaments_blg.tournament_id_blg = matches_blg.tournament_id_blg
WHERE matches_blg.match_id_op IS NULL
GROUP BY tournaments_blg.tournament_id_blg
这将选择所有 tournaments_blg.tournament_id_blg
其中任何一个 matches_blg.match_id_op
是 NULL
.
我怎么只选择全部 tournaments_blg.tournament_id_blg
如果所有的 matches_blg.match_id_op
是 NULL
?
2条答案
按热度按时间u2nhd7ah1#
或
goucqfw62#
试试这个:
SELECT tournaments_blg.tournament_id_blg FROM matches_blg WHERE matches_blg.match_id_op NOT IN (Select tournaments_blg from tournaments_blg )