0

我尝试使用 IP_ID 将一个表中的值更新为另一个表,以按照 sybtax 比较 2 个表

UPDATE EDWID02.CUSTOMER_MOBILE t1
   SET T1.MOBILE = (
      SELECT T2.MOBILE
      FROM EDWID02.NEW_MOBILE t2
      WHERE T1.IP_ID=T2.IP_ID)

我发现的错误是 DB2 数据库错误:

ERROR [21000] [IBM][DB2/AIX64] SQL0811N  The result of a scalar fullselect, 
SELECT INTO statement, or VALUES INTO statement is more than one row.  
SQLSTATE=21000

即使我将 = 更改为它告诉我另一个错误 DB2 数据库错误:

ERROR [42601] [IBM][DB2/AIX64] SQL0104N  An unexpected token "in" was found
following "t1    SET T1.MOBILE".  Expected tokens may include:  "=".
SQLSTATE=42601

我在 DB2 中编码。

4

1 回答 1

0

你的误解

'UPDATE t1 SET value=onevalue'

onevalue 必须是单个值。您可以通过 (SELECT value FROM t2 WHERE t1.id = t2.id FETCH FIRST 1 ROW ONLY)

于 2013-01-14T14:03:59.220 回答