title: Using group by to update multiple records in an update query
body: <p>I have two tables. <code>Table1</code> has company data (<code>Company ID, Company Name ...</code>), so single record for each company. </p>
  
  <p><code>Table2</code> has information about departments in that company (<code>Department ID, Department Name, Company ID, Company Name ...</code> ). So, second table might have n number of records where same company id is used. </p>
  
  <p>Problem is one of our trigger failed to work properly, and no one noticed till now. So, when Company Name was updated in <code>Table1</code>, it never reflected in <code>Table2</code>. </p>
  
  <p>To correct this, I have to do something like the below query:</p>
  
  <pre><code>Update Table2 
  Set 
      [Company Name] = (select [Company Name] 
                        from Table1 
                        where Table2.Company ID = Table1.Company ID)
  Group By Table2.Company ID
  </code></pre>
  
  <p>Basically, I am trying to update all records in <code>Table2</code> to use the same name as <code>Table1</code>, for each record in Table1. </p>
  
  <p>I am a bit confused about how to create the inner select clause. </p>
  
  <p>P.S. Sorry, it might be a bit confusing. Kindly do let me know how to reword it the best.</p>