title: MySQL combine UPDATE and SELECT query
body: <p>I have the following SELECT statement that returns data, example below:</p>
  
  <pre><code>SELECT performers.ID, 
         performers.Name, 
         COUNT(*) AS CountOfDeals, 
         COUNT(DISTINCT(deals.Name)) AS CountOfAliases 
    FROM deals RIGHT JOIN performers 
                 ON deals.name LIKE CONCAT('%', performers.name, '%') 
   WHERE performers.ID IN ( 27952, 27951, 27950, 27949, 27948 ) 
   GROUP BY Name;
  </code></pre>
  
  <p>Example data returned:</p>
  
  <pre><code>  ID        Name             CountOfDeals     CountOfAliases
  27952   Christine Hoberg          1                 0
  27951   Indian Jewelry            1                 0
  27952   Kinky Friedman            5                 3
  27949   KJ-52                     1                 0
  27960   River Whyless             1                 0
  </code></pre>
  
  <p>I want to combine this with the following UPDATE statement </p>
  
  <pre><code>UPDATE performers 
     SET RawAliasCount = CountOfAliases, 
         RawDealCount = CountOfDeals 
   WHERE ID = ?
  </code></pre>
  
  <p>All the values needed to run the update statement are returned in the select statement above so hopefully this should be pretty easy.</p>
  
  <p>Thanks.</p>