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 as id, o.ownername as ownername, p.the_geom as the_geom
FROM parcel p
LEFT JOIN owners o ON =;

Last modified 15 years ago Last modified on Apr 14, 2009, 8:54:53 AM
Note: See TracWiki for help on using the wiki.