I need to get the number of users with rank =player
So far I have tried select count(*) as count_players from users whererank = player
I'm not sure where the error is, if it's only correct in tags and queries, or I'm completely wrong, thanks in advance for any suggestions!
Table:[User]
id | username | password | Ranking |
---|---|---|---|
1 | John | $2y$10$zYharAUmf36hVzkYUg87y.avY | Player |
2 | simple | $2y$10$zYhajiIUGU89887jhgUg87yKJ8G | administrator |
COUNT_PLAYERS = 1
Cully below is right, when you are going after a single result, you don't need to group it. When you group by rank, you do the following (and you don't do "rank='player'").
SELECT COUNT(*) AS count_players FROM users WHERErank='player';
Or if you want to group, choose COUNT(*) AS count_players FROM users GROUP BY ranking.
Have you tried quoting your target ranking? It's a string, not a variable.