Book Errata –

I found a mistake in the How do I do that in PostGIS book on page 4.  When updating a field with results from a related table, I incorrectly referred to an inner SELECT statement.  The new text should read:

==============================================================

Calculations on a related table

You can also use a table relation, and update the value in one table with values in another table that are related by a common field.  In this example we are subtracting the land value in the parvalues table from the asmt value in the parcels table.  To accomplish this, we are explicitly stating that we want to UPDATE parcels, but are referencing the parvalues table in the FROM directive:

 UPDATE parcels
 SET homevalue = parcels.asmt - parvalues.land
 FROM parvalues
 WHERE parcels.parcelkey = parvalues.parcelkey

===============================================================

New versions of the book, starting today, will have this correction*

*for those who have wanted to update a table based on another table, this is a useful query – there are more cool things like this in the book, so go out and pick one up today (or two).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s