title: php/mysql - Compare multiple columns from 2 tables and show biggest differnce
body: <p>I have 1 main table with all my info and 1 table with almost the same structure but slightly different values. Now i want to compare these values and get de highest difference back. I got this working with a query for each column (a1-a5) and in the loop of each query i query again and do some calculations with the results...i dunno, it's messy and i'm not sure how to get this in a clean way.</p>
  
  <p>This is the structure of the 2 tables:</p>
  
  <pre><code>+----------+----------+--------+-----+-----+-----+-----+-----+--------------+
  | HomeTeam | AwayTeam | Result |  a1 |  a2 |  a3 |  a4 |  a5 |  Date        |
  +----------+----------+--------+-----+-----+-----+-----+-----+--------------+
  | team1    | team2    |      H |  5  |  2  |  4  |  4  |  3  |  11-04-2017  |
  | team3    | team4    |      A |  6  |  8  |  4  |  2  |  6  |  11-04-2017  |
  | team1    | team3    |      D |  3  |  7  |  9  |  7  |  2  |  12-04-2017  |
  | team4    | team2    |      H |  2  |  4  |  8  |  6  |  5  |  12-04-2017  |
  +----------+----------+--------+-----+-----+-----+-----+-----+--------------+
  
  +----------+----------+-----+-----+-----+-----+-----+
  | HomeTeam | AwayTeam |  a1 |  a2 |  a3 |  a4 |  a5 |
  +----------+----------+-----+-----+-----+-----+-----+
  | team1    | team2    |  2  |  3  |  5  |  3  |  3  |
  | team3    | team4    |  5  |  7  |  5  |  2  |  3  |
  | team1    | team3    |  4  |  2  |  8  |  6  |  5  |
  | team4    | team2    |  2  |  5  |  5  |  6  |  4  |
  +----------+----------+-----+-----+-----+-----+-----+
  </code></pre>
  
  <p>And this is what i want to print:</p>
  
  <pre><code>team 1 vs team 2 biggest increase was 150% (a1 -&gt; 5 vs 2) on 11-04-2017 
  team 3 vs team 4 biggest increase was 100% (a5 -&gt; 6 vs 3) on 11-04-2017 
  team 1 vs team 3 biggest increase was 250% (a2 -&gt; 7 vs 2) on 12-04-2017 
  team 4 vs team 2 biggest increase was 60% (a3 -&gt; 8 vs 5) on 12-04-2017 
  </code></pre>
  
  <p>While i'm typing this i'm thinking to maybe just use one query to get everything from both tables and use the values to do some calculations? Not sure..someone who can give me a big kick in the right direction on how to do this?</p>