我有这个sql语句:
SELECT game.game_id FROM game, userGame WHERE userGame.user_id = 1
AND userGame.game_id != game.game_id;
我得到这个:
1
1
2
2
3
3
4
4
4
5
5
5
我在 Android 2.1 上的 Sqlite3 数据库上运行语句。
表格是:
USERGAME
--------
userId
gameId
more_columns
GAME
-----
gameId
more_columns
我该如何解决这个错误?
更新:
当 userId=1 时,我想获取所有不在 usergame 表中的游戏 ID。
谢谢。
最佳答案
不存在语法:
select gameID
from game g
where not exists
(select null from usergame ug
where g.gameID = ug.gameID and ug.userID = 1)
关于sql - 愚蠢的sql错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4053143/