Examples Join Tables
An attribute join is often needed when you need to associate a tabular data source with features. A left join is appropriate in this case since we want to retain all the spatial features and append the tabular attributes only where a match occurs.
For example, lets say we have two tables:
- parcel (with an "id" column and spatial geometry)
- owner (with an "id" column and owner information for that parcel id)
CREATE TABLE parceljoin (id integer, ownername text); SELECT AddGeometryColumn('public', 'parceljoin','the_geom','4326','POLYGON',2); INSERT INTO parceljoin SELECT p.id as id, o.ownername as ownername, p.the_geom as the_geom FROM parcel p LEFT JOIN owners o ON o.id = p.id;
Last modified
16 years ago
Last modified on 04/14/09 08:54:53
Note:
See TracWiki
for help on using the wiki.