I'm trying to do something like the following:
UPDATE table1
SET table1.nearest_city_id = subquery.id
FROM
(SELECT id FROM cities ORDER BY cities.location <-> table1.location LIMIT 1)
AS subquery;
i.e. set the nearest city in table 1 based on a spatial query..
But I can't reference the row I'm updating within the subquery. Any way around this?