我有带有纬度、经度和邮政编码的表格。我想选择靠近给定邮政编码和半径(以英里为单位)的记录。例如,用户将输入邮政编码 = 'NW44JL' 和半径 = 1 英里。我需要从表中获取邮政编码“NW44JL”1 英里半径内的所有记录。谁能帮我得到这个。谢谢
Declare @radius int
--Radius for circle
set @radius=1
select distinct tb1.postcodes from table1 tb1
join table1 tb2 on (Power((tb1.latitude - tb2.latitude),2) + POWER((tb1.longitude - tb2.longitude),2)) < POWER(@radius,2)
where tb2.postcodes='NW44JL'
table1 是你的表名
以英里为单位考虑纬度和经度。
如果不需要转换成里程
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)