title: How to update column in a table from another table based on condition?
body: <p>I am having two tables </p>
  
  <ol>
  <li>student table it contains (Student_id,school_code,name,year,...)</li>
  <li>school table it contains (school_id,School_code,School_name,year
  etc.....)</li>
  </ol>
  
  <p>I want to update the school_code column in the student table with the school_id column in the school code table based on school code and year. i m having five years data. so school_id varies for every year. </p>
  
  <p>My query was </p>
  
  <pre><code>UPDATE Master.Student
     SET school_code=( select school_id from Master.school as sc
    JOIN master.student as st
      ON st.school_code=sc.school_code
   WHERE sc.year=x)
   WHERE st.year=x;
  </code></pre>
  
  <p>But its not updating. I am getting error of <code>subquery returns more than one value</code>.</p>