0

This is my query which attempts to return the distance from a specific point to all the records in a table.

This is the Table creation

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fname` varchar(45) DEFAULT NULL,
  `lname` varchar(45) DEFAULT NULL,
  `location` point DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=latin1;

This is the select statement.

`SELECT ST_Distance_Sphere(POINT(-79.3716, 43.6319), location) as distance from user;`

But it produces the following error:

'Error', '1210', 'Incorrect arguments to st_distance_sphere'

How do I get the calculated distance along with data using the point type stored in the database.

This statement works perfectly

SELECT ST_Distance_Sphere(POINT(-79.3716, 43.6319), POINT(-79.3716, 45.6319)) as distance FROM user;
Count Zero
  • 237
  • 2
  • 13
  • Solved. The data which had been inserted into the database had the longitude and latitude in reverse order which resulted in invalid parameters – Count Zero Aug 12 '16 at 18:58

1 Answers1

0

Ensure that the POINT variable stored in the database are in correct order

Count Zero
  • 237
  • 2
  • 13