title: IF...THEN statement in mysql trigger
body: <p>I have two tables:</p>
  
  <pre><code>table A
   id | level_ID | col_m | col_n
  
  table B
   id | prev_ID | cur_ID
  </code></pre>
  
  <p><code>table A</code> is manipulated from the application layer where new inserts are done and updates as well. On the other hand <code>table B</code> has values inserted after an update only on <code>level_ID</code> column of <code>table A</code> via a trigger:</p>
  
  <pre><code>DELIMITER |
  DROP TRIGGER IF EXISTS trigger_happy|
  CREATE TRIGGER trigger_happy AFTER UPDATE ON table A
  FOR EACH ROW
    BEGIN
      IF level_ID!=NEW.level_ID THEN
      INSERT INTO table B (id, cur_ID, prev_ID)
      VALUES (OLD.id, NEW.level_ID, OLD.level_ID)
    END IF;
  END;
  DELIMITER ;
  </code></pre>
  
  <p>The problem is that I intend to have the trigger only fire if there is a change in <code>level_ID</code> column. An update on other columns <code>col_m</code> and <code>col_n</code> should not fire the trigger.</p>
  
  <p>Help me with my trigger statement, because it does not work as it is.</p>
  
  <p>EDIT</p>
  
  <p>Updates the columns are done at different times within the application logic. I need trigger to be fired ONLY when an update on <code>level_ID</code> is done.</p>