我有两张桌子
- 它包含的学生表 (Student_id,school_code,name,year,...)
- 它包含的学校表(school_id、School_code、School_name、year 等.....)
我想根据学校代码和年份用学校代码表中的 school_id 列更新学生表中的 school_code 列。我有五年的数据。所以 school_id 每年都不同。
我的查询是
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;
但它没有更新。我收到错误subquery returns more than one value
。