<div>Hi Thip,</div>
<div>&nbsp;</div>
<div>I recommend filling out your SQL statement much more, and using the 'intersection' within a sub-query.</div>
<div>&nbsp;</div>
<div>Here's an example that uses the 'crosses' test,&nbsp;it returns the features of a polygon table that cross the features of a line table. For my website, it is the data source of a layer that shows forest fire polygons that cross a pipeline, tested&nbsp;on the fly - requiring no pre-processing when new forest fires are added to the dataset.
</div>
<div>&nbsp;</div>
<div>You could modify it for use with 'intersection'.&nbsp;&nbsp;My example checks for an overlap of&nbsp;the bounding boxes of the features before doing the exact 'crosses' test, which speeds up the analysis tremendously.&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp; DATA &quot;the_geom&nbsp;FROM (SELECT layer1.*&nbsp;FROM layer1,&nbsp;layer2&nbsp;WHERE layer1.the_geom &amp;&amp; layer2.the_geom AND CROSSES(layer1.the_geom, layer2.the_geom)&nbsp;AS foo&nbsp;USING UNIQUE&nbsp;gid&nbsp;USING SRID=26910&quot;<br>&nbsp;</div>

<div>Cheers,<br>Ken Lord</div>
<div>Vancouver BC</div>
<div>&nbsp;</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 8/31/05, <b class="gmail_sendername">Matthew Perry</b> &lt;<a href="mailto:perrygeo@gmail.com">perrygeo@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Thip,<br><br>
<div><span class="gmail_quote">On 8/31/05, <b class="gmail_sendername">Thip</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:thip@ait.ac.th" target="_blank">thip@ait.ac.th</a>&gt; wrote:</span>
 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div>
<p><font size="2">DATA &quot; select intersection (twy_sec.the_geom, twy_su.the_geom)&nbsp;using unique gid using SRID=-1&quot;</font></p><span></span></div></blockquote></div>Check this DATA statement against the example in the postgis docs. You may have to rewrite it a bit.
<br><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://postgis.refractions.net/docs/ch04.html#id2512784" target="_blank">http://postgis.refractions.net/docs/ch04.html#id2512784</a> 
<div><span class="e" id="q_1060bb1952b32301_1"><br><br>-- <br>Matt Perry<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:perrygeo@gmail.com" target="_blank">perrygeo@gmail.com</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.perrygeo.net/" target="_blank">
http://www.perrygeo.net</a> </span></div></blockquote></div><br>