title: MySQL Trigger which compares all OLD and NEW for changes need to be simplified
body: <p>I want my "audit" triggers to be simpler to maintain.
  Actually, on a Before update trigger, the logic is as follows :</p>
  
  <pre><code>IF NEW.field &lt;&gt; OLD.field THEN INSERT INTO table SET field=OLD.field
  </code></pre>
  
  <p>I am checking every column for changes because I don't want to store rows which are not really updated. There are many monitored columns and when I change a table (adding or deleting a column), I have to edit the triggers to reflect the new table structure.</p>
  
  <p>Is there a simple way of going through each colum like this :</p>
  
  <pre><code>FOR EACH COL BEGIN IF NEW.COL &lt;&gt; OLD.COL THEN SET changedetected=true; END IF; END
  </code></pre>
  
  <p>And after that, using a FOR loop the same way to populate the Audit table with all the table's columns ?</p>
  
  <p>I don't know if I am being clear enough, please post comments if needed.</p>
  
  <p>Many thanks for your help !</p>