2015-11-19 87 views
0

我有一張表,存儲6個值6列MySQL計數6組合重複

我怎樣才能得到這些6值完全相同的行數量?

我當前的查詢=與冠軍/角色搜索filter = 2272

的獨特組合的量發現,發現的記錄

select item_0,item_1,item_2,item_3,item_4,item_5 from games_player_stats where champion_id = :c '.$query_role.' group by item_0,item_1,item_2,item_3,item_4,item_5 

總量2262

這顯然不工作,但我似乎無法弄清楚如何在這種情況下使用羣組

+0

「完全相同」是什麼意思?你想要返回什麼? –

回答

0

使用SUMGroup by這樣的: -

select 
sum(item_0)+sum(item_1)+sum(item_2)+sum(item_3)+sum(item_4)+sum(item_5) 
from games_player_stats 
where champion_id = :c '.$query_role.' 
group by item_0,item_1,item_2,item_3,item_4,item_5 
+0

這是不正確的。在你分組的領域聚集甚至是錯誤的。 Asker要求記錄6個數值相同的記錄。 – trincot

0

如果你想尋找到item_0 = ITEM_1 = ... = item_5,那麼你可以檢查所有條目:

'select item_0,count(*) 
from games_player_stats 
where champion_id = :c '.$query_role.' 
and item_0=item_1 and item_0=item_2 and item_0=item_3 and item_0=item_4 and item_0=item_5 
group by item_0' 

如果你不是活得t對item_0的不同值感興趣,省略GROUP BY