CREATE TABLE Positions (
id_location int PRIMARY KEY AUTO_INCREMENT,
position POINT NOT NULL
);
INSERT INTO Positions(position) VALUES(POINT(-6.175489, 106.827208));
INSERT INTO Positions(position) VALUES(POINT(-6.173105, 106.808584));
SELECT ST_X(position) AS lat, ST_Y(position) AS lng FROM Positions;
/*
Output
-------------------------
lat lng
-------------------------
-6.175489 106.827208
-6.173105 106.808584
*/
SELECT * FROM Positions;
/*
Output
--------------------------------------------------
id_location position
--------------------------------------------------
1 {"x":-6.175489,"y":106.827208}
2 {"x":-6.173105,"y":106.808584}
*/
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.