Jas
Jas

Reputation: 415

Insert a point into a mysql column

I'm trying to insert a point into a mysql column. However, when I try to retrieve the point, it says just "?? ??"

CREATE TABLE geom (g GEOMETRY);
ALTER TABLE geom ADD pt POINT;
INSERT INTO geom VALUES (GeomFromText('POINT(1 1)'));

The lines above are the ones that I use to create the table and to insert the point.

When I perform SELECT * FROM GEOM, I got the result below enter image description here If you pay attention, these lines are the same available here: https://dev.mysql.com/doc/refman/5.6/en/populating-spatial-columns.html

I spent some hours on this problem and I see many questions here about this issue. None of them helped me to solve the problem. If you know something, please tell me.

Thank you!

Upvotes: 2

Views: 2455

Answers (1)

obe
obe

Reputation: 7808

Try: SELECT ST_AsText(pt) instead.

Read more here: https://dev.mysql.com/doc/refman/5.7/en/gis-format-conversion-functions.html

Upvotes: 1

Related Questions