title: UPDATE SQL Column With SELECT Value
body: <p>I have a column named <code>loanofficer</code> in a table names <code>prequals_created</code> that lists a number corresponding to that loan officer. I want to update this column to have the loan officer name instead of the number, which is located in a table called <code>appusers</code>, where the <code>fullname</code> is matched with the <code>loanofficer</code> id. I am trying to do this by first using SELECT to generate a table of loan officer name and id as a pair by using an "in between" table called <code>loan_pairing</code>. However, something is off about my syntax. Here is my code:</p>
  
  <pre><code>UPDATE 
      prequals_created AS pc
  SET 
      pc.loanofficer = lonames.fullname
  FROM
      (SELECT DISTINCT a.fullname, lp.loanofficer
       FROM appusers AS a
       JOIN loan_pairing AS lp
          ON a.id = lp.loanofficer
       JOIN prequals_created AS pc
          ON lp.loanofficer = pc.loanofficer) AS lonames
  WHERE 
      pc.loanofficer = lonames.loanofficer
  </code></pre>
  
  <p>The SELECT statement nested in the FROM statement is correct, and returns the name of the loan officer paired with their respective id.</p>
  
  <p>What exactly is off about my syntax here?</p>