如何获得表的每个值?

时间:2016-04-17 19:20:39

标签: sqlite

所以我试图检查哪个玩家拥有所有图标,因为查询变成了3个图标:

SELECT PlayerID from OwnedIcon GROUP BY PlayerID HAVING COUNT(IconID)=3;

但是,如果我不想在数字中使用它,那么如果我想稍后添加图标,那么查询将不会发生变化?我试过这个,但似乎错了:

SELECT PlayerID from OwnedIcon GROUP BY PlayerID HAVING COUNT(IconID)= SELECT COUNT (*) FROM Icon;

有没有办法改变它,还是我必须坚持使用数字?

1 个答案:

答案 0 :(得分:1)

SELECT PlayerID 
from OwnedIcon 
GROUP BY PlayerID 
HAVING COUNT(distinct IconID) = (SELECT COUNT(*) FROM Icon)