开发者

How to scroll through a count query in MySQL/PHP

开发者 https://www.devze.com 2023-03-14 15:38 出处:网络
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(

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
0

精彩评论

暂无评论...
验证码 换一张
取 消