本文介绍了如何在mySQL表中插入点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一条mySQL错误,提示"ADDRESS_LONGI_LATIT_LOCATION"不能为null.'geomfromtext/pointfromtext'可能返回空值.怎么了感谢您的帮助.

I get an mySQL error saying 'ADDRESS_LONGI_LATIT_LOCATION' can not be null.Likely that 'geomfromtext/pointfromtext' is returning a null. Whats wrong here? Any help is appreciated.

INSERT INTO address (ADDRESS_NICKNAME,ADDRESS_LONGI_LATIT_LOCATION)
VALUES ('Testing',geomfromtext('Point(10.20.45 34.23.79)'))

另一种方式

INSERT INTO address (ADDRESS_NICKNAME,ADDRESS_LONGI_LATIT_LOCATION)
VALUES ('Testing',pointfromtext('10.20.45 34.23.79'))

推荐答案

按照 ST_geomFromText() 的规范(geomfromtext()是已弃用的同义词,您不应使用它):

As per the specification of ST_geomFromText() (geomfromtext() is a deprecated synonym, you should not use it):

实际上,您的论点的语法格式不正确,因为每个坐标都包含两个点.您可以使用以下简单方法进行检查:

Indeed your argument is not syntactically well-formed, as each coordinate contains two dots. You can check this with a simple:

select geomfromtext('Point(10.20.45 34.23.79)')

结果(尝试在线):

只有一个点,它可以工作:

With a single dot, it works:

select geomfromtext('Point(10.2045 34.2379)')

结果(真正在线)

ST_PointFromText(() ,除了您仍然需要使用 WKT格式,因此您还需要使用POINT():

The same applies to ST_PointFromText((), except you still need to use the WKT format so you need to use POINT() as well:

select pointfromtext('point(10.2045 34.2379)')

结果(尝试在线):

这两个函数基本上相同,除了pointfromtext()会强制得出点结果.

Basically the two functions are the same, except pointfromtext() enforces a point result.

这篇关于如何在mySQL表中插入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 10:58