表结构如下:
-- ----------------------------
-- Table structure for sblocation_table
-- ----------------------------
DROP TABLE IF EXISTS "sblocation_table";
CREATE TABLE "sblocation_table" (
"_id" TEXT,
"address" TEXT,
"lon" REAL,
"createtime" TEXT,
"longitude" TEXT,
"latitude" TEXT,
"lat" REAL,
"type" TEXT,
"owner" TEXT,
PRIMARY KEY ("_id")
);
表结构.png
SELECT DISTINCT
sblocation_table._id,
sblocation_table.address,
sblocation_table.createtime,
sblocation_table.longitude,
sblocation_table.latitude,
sblocation_table.owner,
ROUND(
6378.138 * 2 * ASIN (
SQRT (
POW ( SIN ( ( 34.200317 * PI () / 180 - latitude * PI () / 180 ) / 2 ), 2 ) + COS ( 34.200317 * PI () / 180 ) * COS ( latitude * PI () / 180 ) * POW ( SIN ( ( 108.875249 * PI () / 180 - longitude * PI () / 180 ) / 2 ), 2 )
)
) * 1000
) AS distance_um
FROM
sblocation_table
ORDER BY
distance_um ASC
34.200317 108.875249为输入值
MySql执行结果.png
在Android SqlLite上执行错误
Android SqlLite上执行错误.png
网友评论