I have this query:
select count(*) , ( 3959 * acos( cos( radians( 34.469994 ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians( -118.196739 ) ) + sin( radians( 34.469994 ) ) * sin( radians( lat ) ) ) ) AS distance from users HAVING distance < 150
Which is supposed to get users within 150 miles of开发者_开发问答 a certain latitude and longitude.
How can I get the number of the count(*) part?Also, any idea how to toggle such a query between miles and kilometers?
Thanks!
select count(*) as count, ( 3959 * acos( cos( radians( 34.469994 ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians( -118.196739 ) ) + sin( radians( 34.469994 ) ) * sin( radians( lat ) ) ) ) AS distance from users HAVING distance < 150
精彩评论