jkelly2956
Programmer
Can anyone give me any suggestions on speeding this query up. I have indexes on the lat and longs in both tables. Basically I have a list of places in W_Data....and a list of alternate names for those places in ULocator. I want to do a search for all places where a name contains 'al' and if the original name or one of its alternates is a hit.. I want to show the original name and lat and long.
Code:
SELECT wd.pName,wd.DD_Lat,wd.DD_Long
FROM W_Data wd
LEFT JOIN ULocator ul ON ( 69.09 * DEGREES( ACOS( SIN( RADIANS( ul.Latitude ) ) * SIN( RADIANS( wd.DD_Lat ) ) + COS( RADIANS( ul.Latitude ) ) * COS( RADIANS( wd.DD_Lat ) ) * COS( RADIANS( ul.Longitude - wd.DD_Long ) ) ) ) ) < .1
WHERE ul.pName
LIKE '%al%' OR wd.pName
LIKE '%al%'