'43.005895','-71.013202'
Trying to use:
INSERT INTO table(fanDetLocZip, fanDetLocCity, fanDetLocState, fanDetLocLat, fanDetLocLong, fanDetLocTZ, fanDetLocDST) VALUES(00210, 'Portsmouth', 'NH', '43.005895', '-71.013202', -5, 1);
I’m currently using the datatype SPATIAL
, GEOMETRY
.
Its giving me errors like:
Cannot get geometry object from data you send to the GEOMETRY field
All the values have 2 digits, and 6 decimal places after decimal. How do I store this in mysql?
Error I get when I use:
INSERT INTO Table(fanDetLocZip, fanDetLocCity, fanDetLocState, fanDetLocLatLong, fanDetLocTZ, fanDetLocDST)
VALUES(00210, 'Portsmouth', 'NH', point(43.005895,-71.013202), -5,1)
Error Image:
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can use POINT()
to store into a column of type GEOMETRY
or POINT
:
POINT(43.005895, -71.013202)
If the Geometry column is named geom
, you can use this:
INSERT INTO table ( ..., geom, ...) VALUES ( ..., POINT(43.005895, -71.013202), ...)
If you want to show data stored, you can use the X()
and Y()
functions:
SELECT X(geom) AS x, Y(geom) AS y FROM table
Method 2
Why dont you use instead a Float type for your lat/long?
Float (10,6)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0