title: Mysql After Insert trigger to check new value
body: <p>I have two tables:</p>
  
  <ol>
  <li>oee_main</li>
  <li>oee_client</li>
  </ol>
  
  <p>I already have an after insert trigger on oee_main as follows:</p>
  
  <pre><code>CREATE TRIGGER `oee_upd` AFTER INSERT ON `oee_main`
   FOR EACH ROW UPDATE oee_client
      SET END_DATE= NOW()  where END_DATE IS NULL
  </code></pre>
  
  <p>I now need to develop the trigger even more so that the newly inserted row in oee_main will not only update the END_DATE of oee_client to NOW() where END_DATE is NULL but to only update the row(s) of oee_client where the column called Machine_ID is equal to the newly inserted column named NAME in oee_main.</p>
  
  <p>I have tried adding this to the where condition of the above trigger to no success:</p>
  
  <pre><code>where END_DATE IS NULL and Machine_ID = new.`oee_main`.`NAME`
  </code></pre>
  
  <p>Therefore what I am after is that when a new record is inserted in oee_main which has a value of for example '2' in column 'NAME' the trigger updates only the columns END_DATE of oee_client where NULL and where Machine_ID of oee_client is equal to the newly inserted value of NAME in oee_main.</p>
  
  <p>Thanks</p>