更新语句错误:子查询返回了 1 个以上的值 [英] Update statement error: Subquery returned more than 1 value

查看:32
本文介绍了更新语句错误:子查询返回了 1 个以上的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新列中的所有记录,以便它们以CD"开头,例如DCE206 将成为 CDE206.

I am trying to update all records in a column so that they start with 'CD' e.g. DCE206 would become CDE206.

UPDATE table
SET column = REPLACE(column1, 'DC', 'CD')
WHERE column1 LIKE 'DC%'

我正在使用上述更新语句,但出现以下错误

I am using the above update statement however the following error appears

'子查询返回了 1 个以上的值.当子查询跟随 =、!=、<、<=、>、>= 或当子查询用作表达式时,这是不允许的.'

'Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.'

我是否可以在语句中更改任何内容以实现此目的,或者我是否需要研究使用游标.

Is there anything I can change in the statement to make this happen or do I need to look into using a cursor.

我使用的是 SQL Server 2000.

I am using SQL Server 2000.

推荐答案

您不可能从该代码中得到这个错误.错误肯定来自其他一些代码.

You can't possibly be getting this error from that code. The error msut be from some other peice of code.

除了在更新时运行之外还有什么吗?触发器?

Do you have anything than runs on update? A trigger?

这篇关于更新语句错误:子查询返回了 1 个以上的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆