-1

I have one MyIsam table with geospatial point data. I am contstructing another table from the primary table and am wandering if there is any way to directly copy geo point from one to another via PHP as I do with other data types?

"insert into table2 set charfield='".$cValue."', geopoint='".$GeoData."'"
besimple
  • 444
  • 1
  • 7
  • 12
  • Read up on the [INSERT command](http://dev.mysql.com/doc/refman/5.0/en/insert-select.html) and its syntax – AgRizzo Mar 02 '14 at 00:06
  • as AgRizzo said...you have combined insert and update. – bart2puck Mar 02 '14 at 00:08
  • That does appear to be valid insert syntax, guys, and doesn't relate to the question about the data type. As long as the data types match, you should be able to copy it straight through. – lwitzel Mar 02 '14 at 00:19
  • possible duplicate [mysql insert into table data from another table](http://stackoverflow.com/questions/4241621/mysql-insert-into-table-data-from-another-table?rq=1) – Joel Mar 02 '14 at 00:25
  • use php to invoke sql that does the copying for you. as in insert into foo (f1, f2) select f1, f2 from bar. and yes you are using update syntax. – Rob Mar 02 '14 at 00:51
  • You misundestood me. I know how I could do that easily wiht select insert statement. There is some php code between select and insert and that is what I am asking about - how to transport geopoint data without first converting to text. So far I only see this solution: – besimple Mar 02 '14 at 08:51

1 Answers1

0

The qeuestion can not be answered by simple select insert statement because there is some php code between select and insert and that is what I was asking about - how to transport geopoint data without first converting to text. So far I see this as the best solution:

"select astext(geopoint) as geopointtext from table1" 

and then use this geopointtext as $GeoData in insert from my question:

"insert into table2 set charfield='".$cValue."', geopoint=GeomFromText('".$GeoData."')"
besimple
  • 444
  • 1
  • 7
  • 12