0

I had a normal table. Now i added a spatial column

ALTER TABLE roadData ADD pt POINT ;

and now my table has null values : enter image description here

Now in MySQL tutorial insert statement is used:

INSERT INTO geom VALUES (ST_GeomFromText('POINT(1 1)'));

but i want to to do it in already existing table removing null values and insert point data based on Latitude and Longitude give in each row. Like

INSERT INTO pt VALUES (ST_GeomFromText('POINT(latitude longitude)'));

and also make a spatial index. How can I do it?

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
Arjun Chaudhary
  • 2,373
  • 2
  • 19
  • 36

1 Answers1

1

That's an UPDATE STATEMENT and not an INSERT STATEMENT , try this:

UPDATE geom t
SET t.pt = ST_GeomFromText(CONCAT('POINT(',t.longitude,t.latitude,')'))
sagi
  • 40,026
  • 6
  • 59
  • 84