参数1 :lat
参数2:lng
参数3: lat
参数4: 城市码(可无)
参数5:限制?公里内
参数6:限制查询的数量
1 sqlStr := `SELECT 2 id,longitude,latitude,institution_name,intro,mobile,address,cover, 3 ( 4 6371 * acos ( 5 cos ( radians( ? ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( ? ) ) + sin ( radians( ? ) ) * sin( radians( latitude ) ) 6 ) 7 ) 8 AS 9 distance 10 FROM 11 nts_institution 12 WHERE 13 status=1 AND city=? 14 HAVING 15 distance < ? 16 ORDER BY 17 distance ASC 18 LIMIT ?;`
`SELECT id,longitude,latitude,institution_name,intro,mobile,address,cover, ( 6371 * acos ( cos ( radians( ? ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( ? ) ) + sin ( radians( ? ) ) * sin( radians( latitude ) ) ) ) AS distance FROM nts_institution WHERE status=1 AND city=? HAVING distance < ? ORDER BY distance ASC LIMIT ?;`View Code