2016-01-21 63 views
1

甲骨文更新嗨,我有一个这样的表:其中select语句返回多行错误

ID名称编号

1约翰91234567

2汤姆98765432

3县91357246 。 ..

我想改变数字[91234567]到另一个数字,但我得到这个单行查询返回多于1行。

我的发言:

Update table set number = '9000000' where id = (select id from table where number = '91234567') 

也许我有相同数量的进一步下跌的表中的另一记录。

由于我无法访问该ID,我该如何更改我的声明?谢谢。

回答

3

尝试使用IN代替=

Update table 
set number = '9000000' 
where id IN (select id from table where number = '91234567') 
+1

谢谢..作品非常漂亮..一会儿就会绿色打勾 – user3188291

1

如果需要包含91234567的所有记录更改为9000000:

update table 
set number = 9000000 
where number = 91234567 
+0

很抱歉,但我需要使用主键ID进行更新。对不起,没有明确说明 – user3188291

+0

然后只需使用'ID IN(...'而不是'ID =(' – Aleksej