Database schema
----------------------------------------------------------
| id | killed | killed_by | killed_uuid | killed_by_uuid |
----------------------------------------------------------
killed and killed_by hold the entity type. eg. “Player”, “Environment”, “Creature”. No specifics.
killed_uuid and killed_by_uuid are the userID’s if a player is involved in the kill.
This table holds kills that happens on my game server. Each kill is stored in a separate row so there are no totals for each player.
I want to create the totals for each userID and create a leaderboard from them. So basically, count the rows that for each separate UserID.
I have tried using
select killed_by_uuid, count(id)
from kills
where killed='999' AND killed_by='999'
group by killed_by_uuid
order by count(id) desc
999 being the ID that belongs to a player entity kill NOT an actual USERID. But all I get is a single result set:
Array
(
[0] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[killed_by_uuid] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[1] => 15
[count(id)] => 15
)
1 Answer