我正在尝试根据同一表(学生表)和一列中的另一列更新一列
从另一张 table (学校 table )
代码是:
update student_table
set student_code =
(select l.student_code
from school_table l, student_table n
where l.school = n.schoolname)
我收到以下错误
ORA - 01427 单行子查询返回多于一行
任何帮助,将不胜感激。
最佳答案
对您要完成的工作有一个简单的英语解释会很有帮助。话虽如此,在我看来,您可以使用以下 SQL [假设 school_table 和 student_table 之间存在一对多关系] 将内部选择作为与外部更新语句相关的子查询来完成您想做的事情:
update student_table
set student_code = (select l.student_code
from school_table
where school_table.school = student_table.schoolname)
;
希望这可以帮助。
问候,
罗杰
关于sql - 更新错误 : Receiving Error ORA - 01427 Single-row subquery returns more than one row,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9970480/