
How to use function call in SQL statement
Quote:
> Hello -
> I am trying to generate a query that returns data points that are in a
> certain proximity to a given global location. I am using a VB application
> to access a MS Access database with global locations mapped by latitude and
> longitude. I also have a function that calculates the distance between two
> latitude and longitudes. Is there a way to incorporate this distance
> calculation function into a SQL statement to the database such that it
> returns only those locations that meet a certain distance criteria?
> For example:
> I have point X that has a given latitude and longitude. I want to write a
> query that returns the distance TO each point in the database FROM point X
> using my distance calculation function. Any ideas?
Not unless you can cram the logic into the SQL statement. If you're
using DAO, you can use IIf, Choose, Switch, Log, Sqr, etc. in the SQL.
How are the coordinates actually stored? I suppose if you wanted all
points within, say, 100 km of X, you could calculate what 100 km means
in terms of latitudes and longitudes around X and use the SQL BETWEEN
operator to get everything within a 40 000 km^2 square centered on X
in such a way that will let Jet/Rushmore use indexes for speed.
--
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!