This question was asked ½ a decade ago, but things have changed since then. As stated in @Mapperz’s comment, 5.6 is the first version of MySQL with true full-shape spatial geometry operators and functions. In this version, however, most of the ones that have no prefix (such as your
Within(…) in your code sample but apparently not the
Centroid(…) call) will still execute on Minimum Bounding Rectangles.
Starting in MySQL version 5.7.6, these non-prefixed operators and functions are deprecated and their use highly discouraged because of the ambiguity and incompatibility with the new SQL-MM standard. Instead, if you need full shape support, prefix the operators / functions with “
ST_ (for “Spatial Type”). If you want Minimum Bounding Rectangles versions (say, for performance reasons in use cases where exact shapes aren’t really necessary), prefix with “
MBR_”. Note also that PostGIS 2.x+ also supports the “
ST_” prefix but apparently not the “
MBR_” one, and it, too, has deprecated the non-prefixed variants.
So, your code example would read (and should work in MySQL 5.6+, MariaDB 5.3.3 or 10.x+, and PostGIS 2.x+):
SELECT nazev FROM orp as o, kraje as k WHERE
ST_Intersects(o.geom,k.geom) AND ST_Within(ST_Centroid(o.geom),k.geom) AND
k.nazev = 'Nazev'.
Note that you cannot use the “
ST_” prefix prior to MySQL 5.6! It doesn’t support full-shape spatial functionality until version 5.6, and it’s never heard of keywords beginning with “
MariaDB’s website has a handy Geospatial Support Matrix page comparing the geospatial support functionality of various versions of MySQL (not including the new MySQL 8.x which should at least equal 5.7.6 in terms of spatial support) and MariaDB (including the new MariaDB 10.x). Note that MariaDB, especially the 10.x versions, has better spatial support than the nearest equivalent MySQL version that it’s a drop-in replacement for, including the very useful