I run a pool league and have kept stats in Excel. I want to automate via a website and MySQL will be my primary data analysis tool, though my knowledge there is only at the beginning of a long journey.
I have 2 tables (only showing relevant tables and relevant fields)
users:
--------------------
id BigInt
display_name VarChar(250)
match_results:
---------------------
id BigInt
winner_id BigInt
loser_id BigInt
I want to produce a result set to show as a table of standings, like this:
NAME WINS LOSSES
-------------------------------
User2dn 12 7
User1dn 11 8
User5dn 10 8
etc.
I can manage the ORDER BY
I have other queries where I have successfully joined these two tables to get the display names for both winner_id and loser_id by using 2 different aliases for the same user table and that worked great, but I'm totally baffled here.
What I really need is more complicated than this, since I need to report from multiple other columns in match_results, the max of high_run (as a winner or loser) and bonus points which will be a sum irrespective of winner or loser status. I wanted to keep this question as simple as I could so I could understand it, and then build up the additional complications later. Hope that's OK.