title: compare table by row and per row column to another table
body: <p>I have two tables with the same structure. (refer below)</p>
  
  <pre><code>records = id (int, auto increment), name (varchar 250), age (int), address (varchar 250)
  backup = id (int), name (varchar 250), age (int), address (varchar 250)
  </code></pre>
  
  <p>both table contents 3 records. Now, I want to compare those two tables per row by per column of the row and if there's a row that didnt match to the corresponding row on the compared table then produce and error.</p>
  
  <p>table "records" content:</p>
  
  <pre><code>row 1 : column id = 1, column name = name1, column age = 12, column address = USA
  row 2 : column id = 2, column name = name2, column age = 17, column address = USA
  row 3 : column id = 3, column name = name3, column age = 32, column address = USA
  </code></pre>
  
  <p>table "backup" content:</p>
  
  <pre><code>row 1 : column id = 1, column name = name1change, column age = 12, column address = USA
  row 2 : column id = 2, column name = name2, column age = 17, column address = USA
  row 3 : column id = 3, column name = name3, column age = 32, column address = USA
  </code></pre>
  
  <p>as you can see from the above table contents, in the table "backup row 1, column name" there is a changes, name1 (records table) is changed to name1change (backup table). So when the row 1 of table records is compare to row 1 of table  backup and found a difference, it will then get the row number and column name followed by a text of error (refer below)</p>
  
  <pre><code>echo $errorRow . "with" . $errorColumnOfTheErrorRow . "didn't match, there's is changes";
  </code></pre>
  
  <p>and I want to loop until the end of records with the same process (compare). How to make it? any ideas, help, suggestions and recommendation would be gladly appreciated. Thank you!</p>
  
  <p>so far, what i tried is (refer below)</p>
  
  <pre><code>$sql = "SELECT DISTINCT * FROM (SELECT a.* FROM records a UNION SELECT b.* FROM backup b ) c";
  $result = mysqli_query($this-&gt;db,$sql);
  $sql = "SELECT COUNT(*), id FROM (SELECT DISTINCT * FROM (SELECT a.* FROM records a UNION SELECT b.* FROM backup b ) c ) d GROUP BY id;";
  $result = mysqli_query($this-&gt;db,$sql);
  
  echo $result;
  </code></pre>
  
  <p>as above query, im trying to display the unmatched row but sadly, not working.</p>