title: MySQL - UPDATE query based on SELECT Query
body: <p>I need to check (from the same table) if there is an association between two events based on date-time.</p>
  
  <p>One set of data will contain the ending date-time of certain events and the other set of data will contain the starting date-time for other events.</p>
  
  <p>If the first event completes before the second event then I would like to link them up.</p>
  
  <p>What I have so far is:</p>
  
  <pre><code>SELECT name as name_A, date-time as end_DTS, id as id_A 
  FROM tableA WHERE criteria = 1
  
  
  SELECT name as name_B, date-time as start_DTS, id as id_B 
  FROM tableA WHERE criteria = 2
  </code></pre>
  
  <p>Then I join them:</p>
  
  <pre><code>SELECT name_A, name_B, id_A, id_B, 
  if(start_DTS &gt; end_DTS,'VALID','') as validation_check
  FROM tableA
  LEFT JOIN tableB ON name_A = name_B
  </code></pre>
  
  <p>Can I then, based on my validation_check field, run a UPDATE query with the SELECT nested?</p>