我正在尝试更新一列的多行,如下所示
update persons set salary = (select salary from persons where name = 'John Smith') + 20000;
如果persons
John Smith ,我希望将所有salary
' s name
增加20000。但是我收到了错误
ERROR: more than one row returned by a subquery used as an expression
********** Error **********
ERROR: more than one row returned by a subquery used as an expression
SQL state: 21000
我正在使用Postgresql。
答案 0 :(得分:2)
请改为尝试:
UPDATE persons
SET salary = salary + 20000
WHERE name = 'John Smith';