在POINT列上进行MySQL INSERT/UPDATE [英] MySQL INSERT/UPDATE on POINT column
问题描述
我正在尝试用我所在国家的地理位置填充数据库.我的一张桌子有4个字段:ID [PK],纬度.经度和geoPoint
I'm trying to populate my DB with geographical places of my country. One of my tables have 4 fields: ID[PK], latitude. longitude ande geoPoint
EDIT `SCDBs`.`Punto_Geografico`;
SET @lat = 18.469692;
SET @lon = -63.93212;
SET @g = 'POINT(@lat @lon)';
UPDATE Punto_Geografico SET latitude = @lat, longitude =@lon, geoPoint =@g WHERE idpunto_geografico = 0;
im出现以下错误: 错误代码:1416 无法从发送到GEOMETRY字段的数据中获取几何对象
im getting the following error: Error Code: 1416 Cannot get geometry object from data you send to the GEOMETRY field
我非常确定'geoPoint'字段是具有空间索引的POINT字段.我错过了什么吗?14
I'm pretty sure that 'geoPoint' field is a POINT field with a spatial index. Am i missing anything.14
推荐答案
尝试执行此操作,而不将您的值分配给服务器值.特别是如果它们包含函数调用. MySQL将变量的内容视为纯文本,不会看到其中存在函数调用.
Try doing it without assigning your values to server values. Especially if they contain function calls. MySQL treats the contents of the variables as plain text and won't see that there's a function call in there.
UPDATE ... SET latitude=18, longitute=-63, geoPoint=POINT(18 -63) WHERE ...
这篇关于在POINT列上进行MySQL INSERT/UPDATE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!