如何从其他 table 获取匹配数据?

How to get matching data from other table?

使用 Postgres,我有 2 tables:

如何将来自 table 个邮政编码的几何列数据放入具有匹配邮政编码的 table 个地区?

在查询中:

select t.*, p.geometry
  from territories as t left join postcodes p on t.postcode=p.postcode

只有在邮政编码 table 中没有重复的邮政编码时才有效。

如果要更新 table 个地区,请先添加该列,然后再进行更新:

update territories t set geometry = p.geometry
  from postcodes p
  where t.postcode=p.postcode