Get number of players from mysql
P粉037215587
P粉037215587 2024-02-03 20:10:04
0
1
371

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

P粉037215587
P粉037215587

reply all(1)
P粉306523969

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template