<div dir="ltr">No problem Bob, thank you for your answer.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 11:42 AM, Basques, Bob (CI-StPaul) <span dir="ltr"><<a href="mailto:bob.basques@ci.stpaul.mn.us" target="_blank">bob.basques@ci.stpaul.mn.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS"">All,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS"">Oh, geez, I just realized I wrote my answer using syntax from two different functions.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS"">It should have been more like what Dylan responded with . . . sorry to introduce confusion . . .<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS"">Bobb<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Comic Sans MS""><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a>]
<b>On Behalf Of </b>Daniel GIL<br>
<b>Sent:</b> Thursday, April 02, 2015 10:33 AM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> Re: [postgis-users] Inserting column from another table<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
Hi Dylan. It worked. I thought I tried that yesterday but I probably did something wrong.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
Thank you very much for your answers,<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:.5in">Regards,<br>
<br>
Daniel<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Thu, Apr 2, 2015 at 11:00 AM, Dylan Adams <<a href="mailto:dylan.adams@gmail.com" target="_blank">dylan.adams@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">You'll need to use an UPDATE to accomplish what you're trying to do. It'll probably look something like this<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">UPDATE Table1<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">SET geom = Table2.geom<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">FROM Table2<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">WHERE Table1.FabID = Table2.FabID;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">There's more information in the Postgres' documentation about the UPDATE statement:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><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><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">dylan<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Thu, Apr 2, 2015 at 9:53 AM, Daniel GIL <<a href="mailto:dangimar@gmail.com" target="_blank">dangimar@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Hello, I'm learning SQL/PostGIS and I need some help...<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><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:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;color:#0070c0" lang="CA">SELECT AddGeometryColumn('UDE_spatial','public','table1','geom',4326,'POINT',2);</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
Now, I'm trying to add the values from geom field in Table 2 to geom field in Table 1:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<span style="font-size:10.0pt;color:#0070c0" lang="CA">INSERT INTO Table1(geom)</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<span style="font-size:10.0pt;color:#0070c0" lang="CA">SELECT geom</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<span style="font-size:10.0pt;color:#0070c0" lang="CA">FROM Table2;</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<span style="font-size:10.0pt;color:black" lang="CA">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><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<span style="font-size:10.0pt;color:black" lang="CA">Well, that's probably a very simple question for most of you but I'm getting crazy...lol</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify">
<u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;color:black" lang="CA">Thanks</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<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><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<p class="MsoNormal" style="margin-left:.5in"><br>
_______________________________________________<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><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</div></div></div>
</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>