I am attempting to create a search of a database of people within XX miles from a location. What I have so far is that I pass the sql query three variables:
Latitude: 49.1408
Longitude: -122.318
radius: 1000
From that, I execute the following and it works GREAT. It will return the listings in order of distance.
Executing:
SELECT username, UID, ((ACOS(SIN(49.1408 PI() / 180) SIN(latitude PI() / 180) + COS(49.1408 PI() / 180) COS(latitude PI() / 180) COS((-122.318 - longitude) PI() / 180)) 180 / PI()) 60 * 1.1515) AS distance FROM signup WHERE UID not like '2' HAVING distance<='1000' ORDER BY distance ASC
What I am attempting to do is have it COUNT and return to me the number of users found.
Any help would be greatly appreciated guys!!!