子查询返回了 1 个以上的值。当子查询在 =、!=、<、<=、>、>= 之后时,这是不允许的

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >=

我尝试从 table B 的 select 数据更新 table A 列。但是我遇到了如上所述的错误消息 "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."

请找到我的代码如下:

UPDATE TABLE_A
SET CVT_FACTOR = (SELECT a.CVT_FACTOR
FROM TABLE_A a JOIN TABLE_B b ON a.PROD_CODE = b.PROD_CODE)

请帮助,因为现在已经坚持了几个小时。

如果你只是 运行 子查询 SELECT a.CVT_FACTOR FROM TABLE_A a JOIN TABLE_B b ON a.PROD_CODE = b.PROD_CODE 你会发现它 returns 不止一行。当您使用它来更新值时,这是不允许的。

您可能想要做的是:

UPDATE TABLE_A SET CVT_FACTOR = (
    SELECT TABLE_B.CVT_FACTOR FROM TABLE_B
    WHERE TABLE_B.PROD_CODE = TABLE_A.PROD_CODE
)