Performing Location Query in
Oracle9i
Example:What are the nearest post offices to my office?
Main
Street
163 Island Park Dr.
K1Y 2C3
+
Station
B
K1Y
2C4
3 km
+
Station P
K1Y 2C3
SQL> SELECT P.Post_Office_Name, P.Address
2>
FROM Post_Offices P,
3>
Address_Master A
4>
WHERE
5>
A.St_Address =‘163 Island Park Dr.’
6>
and A.City = ‘Ottawa’
7>
AND
MDSYS.SDO_WITHIN_DISTANCE(
8>
A.Location, P.Location,
9>
‘distance=3’) = ‘TRUE’
;