怎样查询附近的好友?
经度 纬度
122.23423 23.23234
123.23678 23.23456
124.43342 34.23232
都市float类型
查出小数点后2位相同的数据
比如传入 122.23111 23.23111 跟这个经纬度越接近的越排在前
得到结果
经度 纬度
122.23423 23.23234
123.23678 23.23456
数据库是sqlite 或者sqlserver
[解决办法]
- SQL code
declare @T table([经度] numeric(8,5),[纬度] numeric(7,5))insert @Tselect 122.23423,23.23234 union allselect 123.23678,23.23456 union allselect 124.43342,34.23232select * from @Torder by power((纬度-23.23111),2)+power((经度-122.23111),2)/*经度 纬度------------------------------ ------------------------------122.23423 23.23234123.23678 23.23456124.43342 34.23232(3 row(s) affected)*/