Rick Root wrote: > > syntax of my function: getDistance(zip1,long1,lat1,zip2,long2,lat2) > taking either the zip code or the lat/long for each...
> SELECT * > FROM prospects A > WHERE > zipcode in > ( > SELECT B.zipcode > FROM zipcodes B > WHERE > getDistance('27502',0.0,0.0,'',B.latitude,B.longitude) > ) This query is not indexable so it needs to do the math on each and every row. Prequalify the rows by drawing an imaginary box on the map from b.lat + X to b.lat -X and b.lon + X to b.lon -X and finding only the points in that box (the database can do that using an index). Then perform your distance function only on the points in the box. Jochem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:268848 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4