If you have a function distance(zip1,zip2), you can use it in a query:
select a.username, b.username, distance(a.zip_code,b.zip_code)
from user a, user b
where a.username='coolUser' and b.username='blueUser'
If you want all users sorted by distance to a given user, query
select a.username, b.username, distance(a.zip_code,b.zip_code)
from user a, user b
where b.sex = 'M' and b.birthdate > 4-12-1986
and a.username='coolUser' and b.username!=a.username
order by distance(a.zip_code,b.zip_code)
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254