To build a table statement:
CREATE TABLE ts.points ( name VARCHAR (NULL , location not NULL, VARCHAR (+) );
Add the following records:
INSERT intoPoints (name, location)VALUES('P1', Geomfromtext ('Point (Ten)' ) )INSERT intoPoints (name, location)VALUES('P2', Geomfromtext ('Point (one)' ) )INSERT intoPoints (name, location)VALUES('P3', Geomfromtext ('Point (Ten)') )
The query operation is as follows:
SELECT from POINTS
Querying the distance of all records from a specified point
SELECT *,ROUND(6378.138*2*ASIN(SQRT(POW (SIN(X (location)*PI()/ the-Ten*PI()/ the)/2),2)+COS(X (location)*PI()/ the)*COS(Ten*PI()/ the)*POW (SIN(Y (location)*PI()/ the- -*PI()/ the)/2),2)))* +) asDISTANCE fromPOINTSORDER byDISTANCEASC
Note: Point information (10,20), Ps:10 x (longitude), 20 y (latitude)
Find 100 km of data nearby:
SELECTname, X (location), Y (location) frompointsWHEREMbrcontains (LineString ( Point (Ten + - /(111.1 / COS(RADIANS(104.067221))), - + - / 111.1), point ( Ten - - /(111.1 / COS(RADIANS(104.067221))), - - - / 111.1)) , location)
Target point coordinates are (10,20)
MySQL spatial data related operations