Contains is the opposite of Within:
if a polygon contains a point, then the point is inside (within) the polygon
AND not just in the MBR box

I just read the preceding posts And I not sure what you are looking for:
the nearest point to another point or a point within a polygon?
for the nearest, select points inside a box (quick with SQL) and then
SQL SELECT GLength() AS distance
ORDER BY distance
Do you know how to attach a jpeg to a post? is it possible?

Dear Jjc,
Actually first I was looking at the nearest point. Then only I was looking for a point in the polygon. So based on your suggestion I will then use the Within but I am still not clear then when to use contain?

For points in polygon, the choice is not critical:
(g is for geometry)
Within(g1,g2) tell you if point g1 is inside g2 and return 0 (false) or 1 (true)
Contains(g1,g2) tell you if the polygon g1 contains completely the point g2
I don't see any reason to prefer one or the other;
they probably both refer to the same routine.

Dear Jjc,
So in this case both doing the same job right? Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.