title: TSQL: How to update this field
body: <p>I have these tables:</p>
  
  <pre><code>Users
     Id (PK)
     NationalCode
  
  UserProfiles
     UserProfileId (PK) One to One with Users
     SalaryAmount
  
  Salaries
     NationalCode
     SalaryAmount
  </code></pre>
  
  <p>I want to update <code>SalaryAmount</code> for each user inside <code>UserProfiles</code> with new one in Salaries. How can I do that?   </p>
  
  <p>I have tried this:</p>
  
  <pre><code>UPDATE Users
  SET SalaryAmount = t2.Salary
  FROM Users t1
  INNER JOIN Salaries t2 ON t1.NationalCode = t2.NationalCode
  GO
  </code></pre>
  
  <p>The above code works if <code>SalaryAmount</code> be inside <code>Users</code>, But as you can see <code>SalaryAmount</code> is inside <code>UserProfiles</code>.</p>