I am a beginner with PostgreSQL and have two tables A and B, both with multiple columns, including a point column (geom):
TableA includes a given 'ID', geom, etc , TableB is a "DB" of locations with a 'name' column, geom, etc...
Need to find for each TableA.id what is the the 'name' (row columns) and distance of the closest location in TableB.
already could calculate the distance between all points of TableA and TableB with :
ST_DistanceSpheroid(pointA,pointB,[SPHEROID])
But the best could build so far, is a select query where provides for each TAbleA.ID
all distances and respective names from TableB - does not find the minimum for each ID only.
While needed to have the new calculated columns (distance and name) added to Table A.
It is not yet clear to me how to work with data output when using "select" vs an actual table data output. or use of views.
CREATE TABLE
scripts. That's the canonical form to define a table, and we can use it directly to run tests. Ideally provide a fiddle. And always declare your version of Postgres.