问题
I have tried various functions like MBRWithin, MBRContains, Intersects, Contains (all of them found in a plenty of posts around here) but no luck yet. This is the simplified query:
SELECT * FROM users
WHERE Intersects( GeomFromText( 'POINT(50 50)' ), GeomFromText( 'POLYGON(0 0, 100 0, 100 100, 0 100, 0 0)' ) );
I expected it to evaluate that condition as true (like 1=1) and return all users, however this did not happen. Please tell me, what am I doing wrong?
I am running MySql 5.5
回答1:
This worked for me:
SELECT
*
FROM
users
WHERE
MBRContains(
GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))'),
GeomFromText('Point(50 50)')) = 1;
来源:https://stackoverflow.com/questions/16659897/mysql-select-where-polygon-contains-point-always-false