SQL 查询和计算;将查询正确格式化为 select only id

SQL query and calculations; formatting query correctly to select only id

我有一个查询选择 GPS 点 30 英里半径范围内的所有位置。我想获取这些位置的 ID,但它也返回距中心点的距离。

有没有计算距离不返回的方法?

查询:

SELECT id, 3956 * 2 * ASIN(SQRT(
  POWER(SIN((34.1844709 - abs(dest.lat)) * pi()/180 / 2),
  2) + COS(37.7749295 * pi()/180 ) * COS(abs(dest.lat) *
  pi()/180) * POWER(SIN((-118.131809 - dest.lng) *
  pi()/180 / 2), 2) )) as distance
FROM location dest
having distance < 30
ORDER by distance
LIMIT 30

输出:

---------------------------
id    |    distance   
---------------------------
 1    |    2.310
 2    |    2.356
 17   |    4.298

查询基于: http://www.notaires.fr/sites/default/files/geo_searchjkkjkj_0.pdf

你能再做一个select吗?

Select id
From (SELECT id, 3956 * 2 * ASIN(SQRT(
  POWER(SIN((34.1844709 - abs(dest.lat)) * pi()/180 / 2),
  2) + COS(37.7749295 * pi()/180 ) * COS(abs(dest.lat) *
  pi()/180) * POWER(SIN((-118.131809 - dest.lng) *
  pi()/180 / 2), 2) )) as distance
FROM location dest
having distance < 30
ORDER by distance
LIMIT 30) dst