<html><head><base href="x-msg://66/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>George,</div><div><br></div>You need to put source.track_cl into the table list for your query...<div><br></div><div>hint - it is in the table list for your sub-select, but not for the main query, I know some people scorn indenting, but :</div><div><br></div><div><div>SELECT  gid,  name, track_use, st_astext(clipped_geom)</div><div>FROM  (</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>SELECT  source.track_cl.gid,  source.track_cl.name,  source.track_cl.track_use, </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(ST_Dump(ST_Intersection(</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>extents.tiles.the_geom,  source.track_cl.the_geom</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>))).geom  As  clipped_geom</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>FROM  source.track_cl</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>INNER  JOIN  extents.tiles</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ON  ST_Intersects(extents.tiles.the_geom,  source.track_cl.the_geom) </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>WHERE extents.tiles.name='BP33' </div><div>) As  clipped </div><div>WHERE  st_geometrytype(clipped.clipped_geom) = st_geometrytype(source.track_cl.the_geom);</div></div><div><br></div><div>cheers</div><div><br></div><div>Ben</div><div><br></div><div><br></div><div><br><div><div>On 11/05/2011, at 11:15 AM, George Washington wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">Hi, I have the following query:<br><br>SELECT  gid,  name, track_use, st_astext(clipped_geom)<br>FROM  (SELECT  source.track_cl.gid,  source.track_cl.name,  source.track_cl.track_use,(ST_Dump(ST_Intersection(extents.tiles.the_geom,  source.track_cl.the_geom))).geom  As  clipped_geom<br>FROM  source.track_cl<br>INNER  JOIN  extents.tiles<br>ON  ST_Intersects(extents.tiles.the_geom,  source.track_cl.the_geom) where extents.tiles.name='BP33' ) As  clipped<span class="Apple-converted-space"> </span><br>WHERE  st_geometrytype(clipped.clipped_geom) = st_geometrytype(source.track_cl.the_geom);<br><br>which gives me:<br><br>ERROR:  missing FROM-clause entry for table "track_cl"<br>LINE 6: ...metrytype(clipped.clipped_geom) = st_geometrytype(source.tra...<br>SQL state: 42P01<br>Character: 471<br><br><br>On the other hand this version of the same query works (only the last line differs):<br><br>SELECT  gid,  name, track_use, st_astext(clipped_geom)<br>FROM  (SELECT  source.track_cl.gid,  source.track_cl.name,  source.track_cl.track_use,(ST_Dump(ST_Intersection(extents.tiles.the_geom,  source.track_cl.the_geom))).geom  As  clipped_geom<br>FROM  source.track_cl<br>INNER  JOIN  extents.tiles<br>ON  ST_Intersects(extents.tiles.the_geom,  source.track_cl.the_geom) where tiles.name='BP33' ) As  clipped<br>WHERE  ST_Dimension(clipped.clipped_geom)  >0;<br><br>I cannot figure out what is wrong with the first query.<br>Many thanks.<br>George<br>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></blockquote></div><br></div></body></html>