假设我有一个像这样的 2 列表:
| user_id | int(11) | NO | UNI | NULL | |
| utm | point | NO | MUL | NULL | |
如您所见,它非常简单。utm 是Point数据类型。我这样插入:
INSERT INTO mytable(user_id, utm) VALUES(1, PointFromWKB(point(50, 50)));
然后,我创建一个空间索引。
ALTER TABLE mytable ...add spatial index on(utm) or something. (forgot)
好吧,一切都很好。现在,我想选择 * where distance < 99999。 但它不起作用!
//This is supposed to select all where the distance is less than 99999999.
set @mypoint = PointFromWKB(point(20,20))
select * from mytable where GLength(LineString(utm, @mypoint)) < 9999999;
Empty set (0.00 sec)
select * from mytable where GLength(LineStringFromWKB(LineString(utm, @mypoint))) < 9999;
Empty set (0.00 sec)
顺便说一句,我曾尝试在没有 PointFromWKB 的情况下插入 INTO ......但它没有用......这就是为什么有人向我建议 PointFromWKB 的原因。