我有一个准备好的MySQL查询如下。假设team1(第一个表)的成员玩特定的'游戏'('游戏'是team1的一个条目)也可以是team2的成员(第二个表)。我想得到team1的成员数量,这些成员不是team2的成员。但我不知道我哪里出错了,因为查询失败了:
SELECT game, member
FROM team2
WHERE game = :game and member
NOT IN (SELECT member FROM team1 WHERE game = :game)
答案 0 :(得分:0)
对于sql来说有点混淆
试试这个
SELECT t2.game, t2.member
FROM team2 t2
WHERE t2.game = :game
and t2.member
NOT IN (SELECT t1.member FROM team1 t1 WHERE t1.game = t2.game)
order by t2.game
编辑:
如果这没有解决你的问题,(因为你没有说什么发生了什么)。只是分享你的整个代码,看看问题出在哪里。