表instructor
有几列。我只想向列name
添加更多值,并且值来自表student
。条件是只选择name
tot_cred > 100
的学生update instructor
set id = (select id from student where tot_cred > '100');
。我的尝试在下面,但它返回错误。我怎么解决这个问题?
{{1}}
错误就是
子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。
答案 0 :(得分:3)
您需要使用INSERT
语句,而不是UPDATE
语句:
INSERT INTO instructor (id) SELECT id from student where tot_cred > 100;
答案 1 :(得分:0)
update instructor a set
a.name = (
select name from student
where id = a.id
)
where exists (
select '' from student
where id = a.id
and tot_cred > '100'
);