Sql 更新一列中的多行
我正在尝试更新一列中的多行,如下所示Sql 更新一列中的多行,sql,postgresql,Sql,Postgresql,我正在尝试更新一列中的多行,如下所示 update persons set salary = (select salary from persons where name = 'John Smith') + 20000; 在这里,如果姓名是约翰·史密斯,我想将所有人员的工资增加20000英镑。但我犯了一个错误 ERROR: more than one row returned by a subquery used as an expression ********** Error *****
update persons set salary = (select salary from persons where name = 'John Smith') + 20000;
在这里,如果姓名
是约翰·史密斯,我想将所有人员的工资
增加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。请尝试以下方法:
UPDATE persons
SET salary = salary + 20000
WHERE name = 'John Smith';