I have two tables: point1 and point2. For each point from table point1, I want to find the closest point from table point2.
For example: For point with id=1 from table point1, the closest point from table point2 has id (?? I want to get that id).
I tried to use ST_ClosestPoint but but it did not work properly. My code:
SELECT ST_ClosestPoint(pont2.geom, (SELECT point1.geomxy WHERE point1.id=1))
FROM pint2, point1