So I have two tables, one table is called stores which has the name of the store as well as the geom column that contains the coordinates for the stores. The other table is customers which has the coordinates of the customer's address.
I'm trying to create a new column in the customer table with the nearest store given the customer's coordinates. I've tried something like this but it doesn't work:
UPDATE customers SET storename =
SELECT storename
FROM stores
ORDER BY geom <-> ST_GeometryFromText('POINT(customers.geom)',4326) LIMIT 1
);