postgresql SQL更新集子查询

6yoyoihd  于 2022-12-18  发布在  PostgreSQL
关注(0)|答案(1)|浏览(226)

问题是我无法在set语句中使用子查询更新表
错误无效查询:代码:8001上下文:单行子查询返回多个行查询:3109398地址:

update tableA as A
set name = name || ',' || (select distinct B.number
from tableB as B
where B.number is not null
and B.ID like 'ID%'
order by B.number) || ',' 
where C.number = (select number from tableC
                   where C.number = 1)

当name = name+"",+B.number.的值时,预期结果是更新表A的名称列,条件是将列名称的值替换为C.number。

o2rvlv0m

o2rvlv0m1#

update tableA as A
set name = name || ',' || (select distinct B.number
from tableB as B
where B.number is not null
and B.ID like 'ID%'
order by B.number) || ',' 
where C.number in (select number from tableC
                   where C.number = 1)

您应该将“Where C.Number =“更改为“Where C.Number in“

相关问题