<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>Have you tried</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>SELECT a.gid, a.the_geom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>FROM a INNER JOIN b ON (b.gid = 100 AND 
ST_DWithin(a.the_geom, b.the_geom,1) )</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>WHERE NOT ST_Within(a.the_geom, 
b.the_geom)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>Hope that helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=062000110-14082008><FONT face=Arial 
color=#0000ff size=2>Regina</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Brian 
Sanjeewa Rupasinghe<BR><B>Sent:</B> Thursday, August 14, 2008 5:53 
AM<BR><B>To:</B> postgis-users@postgis.refractions.net<BR><B>Subject:</B> 
[postgis-users] Spatial Query<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>I have polygon features in PostgreSQL database. How can i make</DIV>
<DIV>a query to find all polygons that are within a distance of say 1m 
from</DIV>
<DIV>polygon id = 100. Query should not select polygons that are within 
polygon</DIV>
<DIV>id = 100.</DIV>
<DIV>I used ST_WIthindistance, but it selcted all insidepolygons too. 
Please</DIV>
<DIV>help me if you have any sample code or clue.</DIV>
<DIV> </DIV>
<DIV>Thanks in advance,</DIV>
<DIV> </DIV>
<DIV>Sanjeewa.</DIV></BODY></HTML>