Skip to content

Commit 0b90098

Browse files
authored
Merge pull request #1 from dvohra09/patch-4
Update point-data-type.sql
2 parents 1480836 + 54dca33 commit 0b90098

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
-- Create example table
2-
CREATE TABLE locations (
2+
CREATE TABLE Locations (
33
id INT AUTO_INCREMENT PRIMARY KEY,
44
name VARCHAR(255),
55
coordinates POINT NOT NULL SRID 4326,
66
SPATIAL INDEX(coordinates)
77
);
88
-- Add example data
9-
INSERT INTO locations (name, coordinates)
9+
INSERT INTO Locations (name, coordinates)
1010
VALUES ('Eiffel Tower', ST_PointFromText('POINT(2.2945 48.8584)', 4326));
11+
INSERT INTO Locations (name, coordinates)
12+
VALUES ('Arc de Triomphe', ST_PointFromText('POINT(2.2950 48.8738)', 4326));
1113
-- 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;
14+
SELECT
15+
ST_Distance_Sphere(t1.coordinates, t2.coordinates) AS Distance_in_Meters
16+
FROM
17+
Locations AS t1,
18+
Locations AS t2
19+
WHERE
20+
t1.name = 'Eiffel Tower' AND t2.name = 'Arc de Triomphe';

0 commit comments

Comments
 (0)