繁体   English   中英

来自select的postgresql更新列

[英]postgresql update column from select

我正在尝试使用选择查询从一个表中更新一列。

它运行并将整个type_列更新为religious (文本字段)。

我试图只更新宗教几何与宗地几何相交的行。

update wash_parcels_final
set    type_ = t.religious 
from   (select wash_worship.religious 
        from   wash_parcels_final 
        join   wash_worship 
        on     st_intersects(wash_worship.geom, wash_parcels_final.geom)) t

我想这就是你想要的:

update wash_parcels_final
    set type_ = ww.religious 
    from wash_worship ww  
    where st_intersects(ww.geom, wash_parcels_final.geom);

我使用 PgAdmin4 和最新版本的 PostgreSQL,这个查询对我有用:

update public."UserPoints"
set "AvailablePoints" = up."AvailablePoints" + tc."CLV"
from public."UserPoints" up join public."TEMPCLV" tc on up."UserId" = tc."CUSTOMER_NUMBER"

希望帮助别人!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM