Using POINT DataType to store Lat,Lng from GPS (MySQL 5.7)

CREATE TABLE Positions ( id_location int PRIMARY KEY AUTO_INCREMENT, position POINT NOT NULL ); INSERT INTO Positions(position) VALUES(POINT(106.827208, -6.175489)); INSERT INTO Positions(position) VALUES(POINT(106.808584, -6.173105)); SELECT X(position) AS lat, Y(position) AS lng FROM Positions; /* Output (Lng = X-axis, Lat=Y-Axis) ------------------------- lng lat ------------------------- 106.827208 -6.175489 106.808584 -6.173105 */ SELECT * FROM Positions; /* Output -------------------------------------------------- id_location position -------------------------------------------------- 1 {"x":106.827208,"y":-6.175489} 2 {"x":106.808584,"y":-6.173105} */
MySQL 5.7

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.