[postgis-users] Inserting column from another table
Basques, Bob (CI-StPaul)
bob.basques at ci.stpaul.mn.us
Thu Apr 2 07:59:38 PDT 2015
A hint to get you started . .
INSERT INTO <tablename> VALUES (SELECT <something> FROM . . . . )
Bobb
From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Daniel GIL
Sent: Thursday, April 02, 2015 9:53 AM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] Inserting column from another table
Hello, I'm learning SQL/PostGIS and I need some help...
I have a table (Table1) with different fields (but no geometry field). This table has already 35 rows of values.
I imported a second Table to the same database in pgAdmin using pgShapeLoader. This second table has a geom field that I want to add to Table1. The idea is to convert a non-spatial table to spatial
I created a geom field in Table 1 using AddColumn:
SELECT AddGeometryColumn('UDE_spatial','public','table1','geom',4326,'POINT',2);
Now, I'm trying to add the values from geom field in Table 2 to geom field in Table 1:
INSERT INTO Table1(geom)
SELECT geom
FROM Table2;
There are 35 rows to add and a common field 'FabID'. My surprise is that instead of adding the values in the rows from 1 to 35, it starts in the row number 36. It seems like you only could use INSERT INTO...SELECT when you want to add fields to a new table with no values added yet. I don't know how to write the sentence in the way I need. I tried adding...WHERE fabid BETWEEN 1 AND 35.
Well, that's probably a very simple question for most of you but I'm getting crazy...lol
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150402/e7b6f61d/attachment.html>
More information about the postgis-users
mailing list