We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e8a096 commit 008c87aCopy full SHA for 008c87a
sql-queries-12/ideal-data-type-latitude-longitude-mysql/point-data-type.sql
@@ -0,0 +1,16 @@
1
+-- Create example table
2
+CREATE TABLE locations (
3
+ id INT AUTO_INCREMENT PRIMARY KEY,
4
+ name VARCHAR(255),
5
+ coordinates POINT NOT NULL SRID 4326,
6
+ SPATIAL INDEX(coordinates)
7
+);
8
+-- Add example data
9
+INSERT INTO locations (name, coordinates)
10
+VALUES ('Eiffel Tower', ST_PointFromText('POINT(2.2945 48.8584)', 4326));
11
+-- Query example data
12
+SELECT name,
13
+ST_Distance_Sphere(coordinates,
14
+ ST_PointFromText('POINT(49.2827 -123.1207)', 4326))
15
+ AS distance_meters
16
+FROM locations;
0 commit comments