【发布时间】:2021-12-28 21:14:06
【问题描述】:
在这个查询*中,我按纬度、经度、各种标准……从近到远或得分及其工作/列出数据列出并排序“mytableabc”中的行,我认为它足够好/足够快!?
select
round((6371 * acos(cos(radians('40.123456')) * cos(radians(latitude)) * cos(radians(longtitude) - radians('29.123456')) + sin(radians(latitude)) * sin(radians('40.123456')))), (2)) as distance,
(match(colone,coltwo) against('searchkeywordabc' in boolean mode)) as score,
id,colone,coltwo,latitude,longtitude,colthree
from mytableabc
where (colone='sampleforsomething')
and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
having distance <= 5 order by distance asc limit 0,50
--问题
在不同的行和文件中,我只需要具有相同条件的返回元素的总数 count(id)... 我尝试添加计数(id),但它没有给出正确的计数总数和列表行,我只想要总数(就像通常计数查询一样)而不是数据行
select
count(id),
round((6371 * acos(cos(radians('40.123456')) * cos(radians(latitude)) * cos(radians(longtitude) - radians('29.123456')) + sin(radians(latitude)) * sin(radians('40.123456')))), (2)) as distance,
(match(colone,coltwo) against('searchkeywordabc' in boolean mode)) as score,
id,colone,coltwo,latitude,longtitude,colthree
from mytableabc
where (colone='sampleforsomething')
and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
having distance <= 5 order by distance asc limit 0,50
--这个没有距离/纬度/经度标准的查询也很好用,只返回总数......但我需要在这个查询中添加距离查询
select count(id) from mytableabc where (colone='sampleforsomething') and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
我不是 sql 专家,是的,正如您所见,我需要一个。 谢谢。
【问题讨论】:
标签: php mysql geolocation mariadb