I just created a new GEOMETRY column p and need to populate values for all existing rows in the table for p based on existing values in cols lat and lng.
Problem: Updating a single column using the query below works well because I typed in the lat and lng values manually. But when I want MySQL to update col p for all rows in the tables, the query that I used does not set any values to col p. I think it has to do with the sub-query (?), but I am not sure how to make it work properly. Thanks!
Query that works
UPDATE listings
SET p = GeomFromText('POINT(39.948177 -75.174324)')
WHERE listing_id = '585221';
Query that sets no value
Added a WHERE clause so I dont destroy the entire table when testing. I actually want to do the UPDATE query for ALL rows in the table
UPDATE listings
SET p = GeomFromText('POINT(lat lng)')
WHERE listing_id = '585221';
and what about this (remove the geomfromtext function)
UPDATE listings
SET p = POINT(lat, lng)
WHERE listing_id = ‘585221’;
or you can go like this
UPDATE listings SET p = GeomFromText(CONCAT(‘POINT(‘,lat,’ ‘,lng,’)’));