title: SQL update one column from another column in another table
body: <p>I read various post's prior to this. but none of them seemed to work for me. </p>
  
  <p>As the title suggests, I am trying to update one column from a column in another table. I don't recall having problems with this before..</p>
  
  <p><b>1.</b> Table: user_settings.contact_id, I want to update with contacts.id <code>where (user_settings.account_id == contacts_account_id)</code></p>
  
  <p><b>2.</b> Previously Contacts were linked to user accounts via the account_id. However, now we want to link a contact to <code>user_settings</code> via <code>contacts.id</code></p>
  
  <p>Below are a few examples of what I have tried, though none of them have worked. I would be interested in A.) Why they don't work and B.) What should I do instead.</p>
  
  <p>Example A:</p>
  
  <pre><code>UPDATE user_settings
  SET user_settings.contact_id = contacts.id 
  FROM user_settings 
  INNER JOIN contacts ON user_settings.account_id = contacts.account_id
  </code></pre>
  
  <p>Example B:</p>
  
  <pre><code>UPDATE (SELECT A.contact_id id1, B.id id2
    FROM user_settings A, contacts B
    WHERE user_settings.account_id = contacts.account_id)
  SET id1 = id2
  </code></pre>
  
  <p>Example C:</p>
  
  <pre><code>UPDATE user_settings
  SET user_settings.contact_id = (SELECT id
    FROM contacts
    WHERE (user_settings.account_id = contacts.account_id)
  WHERE EXISTS ( user_settings.account_id = contacts.account_id )
  </code></pre>
  
  <p>I feel like my brain just shutdown on me and would appreciate any bumps to reboot it. Thanks :)</p>