在PostgreSQL
update table1 t1 set t1.name=(select t2.name from table2 t2 where t1.id=t2.id)
where exists (select 1 from table2 t2 where t1.id=t2.id)
中这样的语句应该怎么写
貌似PostgreSQL 中upate,delete 都不支持子查询
...全文
115511打赏收藏
关于PostgreSQL update 关于子查询的问题
在PostgreSQL update table1 t1 set t1.name=(select t2.name from table2 t2 where t1.id=t2.id) where exists (select 1 from table2 t2 where t1.id=t2.id) 中这样的语句应该怎么写 貌似PostgreSQL 中upate,delete 都不支持子查询
Update "DW_CUUSER_MI_M3390_201010" set "belongs_area_code"="dw_pz_cuuser_mi_200712"."belongs_area_code"
from "dw_pz_cuuser_mi_200712" where "DW_CUUSER_MI_M3390_201010"."user_id"= "dw_pz_cuuser_mi_200712"."user_id"
and "DW_CUUSER_MI_M3390_201010"."belongs_area_code"<>"dw_pz_cuuser_mi_200712"."belongs_area_code"
and "DW_CUUSER_MI_M3390_201010"."create_date" < to_date('20080101', 'yyyymmdd')
and "DW_CUUSER_MI_M3390_201010"."svcid" = 'G' and "DW_CUUSER_MI_M3390_201010"."area_id"='390'
and "DW_CUUSER_MI_M3390_201010"."svcsubid" = 2
Update DW_CUUSER_MI_M3390_201010 t1 set belongs_area_code=t2.belongs_area_code
from dw_pz_cuuser_mi_200712 t2 where t1.user_id = t2.user_id
and t1.belongs_area_code<>t2.belongs_area_code
and t1.create_date < to_date('20080101', 'yyyymmdd')
and t1.svcid = 'G' and t1.area_id='390'
and t1.svcsubid = 2
报错:
ERROR: Cannot parallelize that UPDATE yet
DETAIL: Passage of data from one segment to another is not yet supported during UPDATE operations.
HINT: The WHERE condition must specify equality between corresponding DISTRIBUTED BY columns of the target table and all joined tables.
********** 错误 **********
ERROR: Cannot parallelize that UPDATE yet
SQL 状态: 0AM01
详细:Passage of data from one segment to another is not yet supported during UPDATE operations.
指导建议:The WHERE condition must specify equality between corresponding DISTRIBUTED BY columns of the target table and all joined tables.
原SQL 是这样的
Update DW_CUUSER_MI_M3390_201010 t1 set
belongs_area_code = (select t2.belongs_area_code
from dw_pz_cuuser_mi_200712 t2
where t1.user_id = t2.user_id
and t1.belongs_area_code<>t2.belongs_area_code
and t1.create_date < to_date('20080101', 'yyyymmdd')
and t1.svcid = 'G' and t1.area_id='390'
and t1.svcsubid = 2)
where exists (select 1
from dw_pz_cuuser_mi_200712 t2
where t1.user_id = t2.user_id
and t1.belongs_area_code<>t2.belongs_area_code
and t1.create_date < to_date('20080101', 'yyyymmdd')
and t1.svcid = 'G' and t1.area_id='390'
and t1.svcsubid = 2)
错误
ERROR: Greenplum Database does not yet support that query.
DETAIL: The query contains a correlated subquery.
********** 错误 **********
ERROR: Greenplum Database does not yet support that query.
SQL 状态: 0AM00
详细:The query contains a correlated subquery.