型号:
function mapdisplay($lat1,$lng1,$cid2)
{
$this->db->select("cname,frmid,frno,(6371 * acos( cos( radians('$lat1') ) * cos( radians(lat) ) * cos( radians(longi) - radians('$lng1') ) + sin( radians('$lat1') ) * sin( radians(lat) ) ) )AS distance)");
$this->db->from("tablefir");
$this->db->where("frmid NOT IN ($cid2)");
$this->db->having("distance <= 1");
$this->db->order_by("distance LIMIT 20");
$query = $this->db->get();
return $query->result();
}
错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MariaDB服务器版本,以获得正确的语法 靠近')FROM(
tablefir
)WHEREfrmid
NOT IN(5,10)HAVING 第1行distance
&lt; = 1 ORDER BY'
SELECT `crimehead`
,`frmid`
,`firno`
,(6371 * acos(cos(radians('15.859151')) * cos(radians(lat))
* cos(radians(longi) - radians('74.513124')) + sin(radians('15.859151'))
* sin(radians(lat)))) AS distance )
FROM (`tablefir`)
WHERE `frmid` NOT IN (
5
,10
)
HAVING `distance` <= 1
ORDER BY `distance` LIMIT 20
答案 0 :(得分:2)
你给了一个额外的结束括号,用这个
更改你的查询SELECT crimehead
,frmid
,firno
,(6371 * acos(cos(radians('15.859151')) * cos(radians(lat))
* cos(radians(longi) - radians('74.513124')) + sin(radians('15.859151'))
* sin(radians(lat)))) AS distance
FROM (tablefir)
WHERE frmid NOT IN (
5
,10
)
HAVING distance <= 1
ORDER BY distance LIMIT 20;