SELECT team
FROM (
SELECT tid team, WINS.ltid otherteam
FROM TEAMS
LEFT JOIN WINS ON WINS.wtid = tid
UNION ALL
SELECT tid team, LOSE.wtid otherteam
FROM TEAMS
LEFT JOIN WINS LOSE ON LOSE.ltid = tid
)
GROUP BY team
HAVING COUNT(DISTINCT otherteam) >= (SELECT COUNT(tid)-1 AS teamcount FROM TEAMS)otherteams
SELECT
t1.tid
FROM
teams t1
WHERE
NOT EXISTS( SELECT
t2.tid
FROM
teams t2
WHERE
t2.tid NOT IN (SELECT
wtid
FROM
wins
WHERE
ltid = t1.tid UNION (SELECT
ltid
FROM
wins
WHERE
wtid = t1.tid)) AND t1.tid != t2.tid)
2条答案
按热度按时间gdrx4gfi1#
这样做可以:
7gs2gvoe2#
这对我有用。