title: MySQL Update Subset Having
body: <p>I have three tables: contacts, domains, and contacts_domains, which form a many-to-many relationship.</p>
  
  <p>I would like to run a query that updates the contacts_domains table, but only for domains that have exactly one contact.</p>
  
  <p>I know how to SELECT the rows I'm interested in, but not how to UPDATE them.</p>
  
  <pre><code>SELECT domain_id, contact_id, dominant
  FROM contacts_domains
  GROUP BY domain_id
  HAVING COUNT(contact_id) = 1
  </code></pre>
  
  <p>I want to set contacts_domains.dominant = 1 for all these results.</p>
  
  <p>Thanks!</p>