title: MySQL query with matching and sum - League Table
body: <p>I have 5 tables:</p>
  
  <ul>
  <li>Players (id, name, team_id)</li>
  <li>Teams (id, name)</li>
  <li>Results (id, game_id, player.id, position)</li>
  <li>Games (id, location)</li>
  <li>Score (position, score)</li>
  </ul>
  
  <p>as <a href="https://i.stack.imgur.com/D5SJ1.png" rel="nofollow noreferrer">follows</a></p>
  
  <p><img src="https://i.stack.imgur.com/D5SJ1.png" alt="enter image description here"></p>
  
  <p>I want to make a league table like <a href="https://i.stack.imgur.com/xKXnV.png" rel="nofollow noreferrer">this</a> </p>
  
  <p><img src="https://i.stack.imgur.com/xKXnV.png" alt="enter image description here"></p>
  
  <p>I am confused how to sum up the scores for each player. This is my code so far:</p>
  
  <pre><code>SELECT Players.name, Teams.name, Results.position FROM Players
  INNER JOIN Teams ON Players.team_id = Teams.id
  JOIN Results ON Player.id = Results.player_id
  JOIN Scores ON Results.position = Scores.scores
  </code></pre>
  
  <p>Any idea?</p>