oracle 错误码284,284:子查询返回的不是一行(284: A subquery has returned not exactly one row)...

I'm trying to do an update massive to a table in INFORMIX, but my query returns this error:

284: A subquery has returned not exactly one row

This is my query:

update newLocations set

description=

(select unique b.description from newLocations a,locations b

where a.id_location=b.id_location )

Here are mi locations table

Table: locations

id_location id2_location description

02 AAA00 AS-LOC1

05 AA000 AS-LOC2

10 AA010 AS-LOC7

20 AA020 AS-LOC8

30 AA030 AS-LOC9

40 AA040 AS-LOCA

50 AA050 AS-LOCB

Here are mi newLocations table

Table: newLocations

id_location description

02

05

05

05

05

05

10

20

30

40

50

My subquery returns:

AS-LOC1

AS-LOC2

AS-LOC7

AS-LOC8

AS-LOC9

AS-LOCA

AS-LOCB

How can I do to assign the description in newLocations, relating id_location from locations?

This is the solution, thanks to Joseph B

update newLocations

set description=

(select max(l.description)

from locations l

where newLocations.id_location=l.id_location)

where exists

(select 1

from locations l2

where newLocations.id_location=l2.id_location);

And this error:

201: A syntax error has occurred.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值