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 ST_X(position) AS lat, ST_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 8.0
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.