Hi Sunpeng,<br><br>Definitely use ST_DWithin.<br><br>-Francis<br><br><div class="gmail_quote">On 13 September 2010 06:51, sunpeng <span dir="ltr"><<a href="mailto:bluevaley@gmail.com">bluevaley@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi, <br> I've the following table,and has created the index on uid and location;<br><div style="margin-left: 40px;">

CREATE TABLE points<br>(<br>  location geometry, //assume it's a 2-dimension point<br>  uid integer<br>

)<br></div><br>Now, I've a point P with uid= 12345, and want to find the neighbors which are within 20, how to write the sql?Is this right?<br><div style="margin-left: 40px;">select st_astext(location)<br>from points a, points b<br>



where b.rid = 12345 and ST_DWithin(a.the_geom, b.the_geom, 20)<br><br>or use st_buffer? which one is more efficient ? <br><br></div>Thanks!
<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" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br>