<div dir="ltr"><div><div>Hi Dylan. It worked. I thought I tried thatĀ  yesterday but I probably did something wrong.<br><br></div>Thank you very much for your answers,<br><br></div>Regards,<br><br>Daniel<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 11:00 AM, Dylan Adams <span dir="ltr"><<a href="mailto:dylan.adams@gmail.com" target="_blank">dylan.adams@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You'll need to use an UPDATE to accomplish what you're trying to do. It'll probably look something like this<div><br></div><div>UPDATE Table1</div><div>SET geom = Table2.geom</div><div>FROM Table2</div><div>WHERE Table1.FabID = Table2.FabID;</div><div><br></div><div>There's more information in the Postgres' documentation about the UPDATE statement:</div><div><br></div><div><a href="http://www.postgresql.org/docs/9.4/interactive/sql-update.html" target="_blank">http://www.postgresql.org/docs/9.4/interactive/sql-update.html</a><br></div><div><br></div><div>Regards,</div><div>dylan</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Apr 2, 2015 at 9:53 AM, Daniel GIL <span dir="ltr"><<a href="mailto:dangimar@gmail.com" target="_blank">dangimar@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello, I'm learning SQL/PostGIS and I need some help...<br><div><br>I have a table (Table1) with different fields (but no geometry field). This table has already 35 rows of values.<br><br>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<br><br>I created a geom field in Table 1 using AddColumn:<br>

<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><br></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal">

</p><p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA">SELECT AddGeometryColumn('UDE_spatial','public','table1','geom',4326,'POINT',2);</span></p>

<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><br><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal">Now, I'm trying to add the values from geom field in Table 2 to geom field in Table 1:<br><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA">INSERT INTO Table1(geom)</span></p>

<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA">SELECT geom</span></p>

<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA">FROM Table2;</span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><br><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"><span style="color:rgb(0,0,0)">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.</span></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><br><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"><span style="color:rgb(0,0,0)"></span></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"><span style="color:rgb(0,0,0)">Well, that's probably a very simple question for most of you but I'm getting crazy...lol<br></span></span></p><p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal"><br><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"><span style="color:rgb(0,0,0)"></span></span></p><span style="font-size:10pt;color:rgb(0,112,192)" lang="CA"><span style="color:rgb(0,0,0)">Thanks</span></span></div></div>
<br></div></div>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>