Model:
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();
}
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') FROM (
tablefir
) WHEREfrmid
NOT IN (5,10) HAVINGdistance
<= 1 ORDER BY ' at line 1
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
You given one extra closing braces, change your query with this
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.