Bug #5039 unable to get distance function in 4.1 beta to work
Submitted: 13 Aug 2004 21:46 Modified: 13 Dec 2007 15:36
Reporter: David Robertus Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:4.1.4 OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any

[13 Aug 2004 21:46] David Robertus
Description:
I have a single table and I am trying to retrieve the distance between two geometries in the table using the following syntax:

SELECT distance(b.geom, b2.geom) as dist
FROM small_geo.boundaries b, small_geo.boundaries b2
WHERE b.id = 1 and b2.id = 2

The returned error message is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(b.geom, b2.geom) as dist
FROM small_geo.boundaries b, small_geo.boundaries b2
' at line 1

I have tried several other approaches to using this function so far without success.  Can I get a pointer on the usage of the function, please?

How to repeat:
Create a table with two columns: and ID and a geometry column.  Insert two geometries with distinct IDs that are spatially separate from one another (I just have two simple boxes).  Try to use the distance function in SQL context to determine the minimum distance between the geometries.

Suggested fix:
The above usage of the distance function is fairly standard among other spatially enabled databases and I believe that it is being used in the ASNI-compliant format.  If there is another way that this function should be called I have not been able to get it to work.
[13 Aug 2004 22:43] Dean Ellis
Verified against 4.1.4; function does not appear to exist.
[13 Aug 2004 23:40] Paul DuBois
As documented, Distance() is not yet implemented.

http://dev.mysql.com/doc/mysql/en/
Functions_that_test_spatial_relationships_between_geometries.html