I have a table of clients with their home addresses. I have another table with districts and their polygons. I want to create a new column in the client table with the name of the district in which they live.
I thought this would work:
alter table ua
add column district varchar;
update ua
set district = ((select uk_lad.geo_label from uk_lad where ST_Contains(uk_lad.geom,ua."east/north")='True'));
where ua is the client table, uk_lad the district one, geom being the district polygons and "east/north" the clients' addresses.
Not sure how to insert unique values from another table. I'm assuming with some type of spatial join, but not sure how I would implement that.
question from:
https://stackoverflow.com/questions/65875182/set-a-column-as-a-unique-value-from-another-table-postgresql 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…