Menu
Morning Folks,
A tricky query if someone may help.
I’ve got two tables which I’m needing to do some basic math on. First one is a game table, second one is a player table.
It’s a weird format and it’s not my table structure. In each game row I have player1Id and player2Id.
I need to count all games and find out who had the most games. Sometimes a player will be player1 sometimes they’ll be player2.
I had tried something like this but it’s not working
[code]
SELECT COUNT(g.gameId) as TTL, p.playerId FROM `games` g
JOIN players p ON p.playerId = g.player1Id OR g.player2Id
GROUP BY p.playerId
order by COUNT(g.gameId) desc