PDA

View Full Version : convert one field to another?


sitNsmile
02-11-2010, 05:27 PM
Okay if I build a new database, and wanted to convert the old one into it.. heres example. but how could I do it, and or would I need to build a php code to develop that?


say we have `links` -> linkid, linktitle, linkstatus
and if I wanted to convert that into my new database (the actually "data")

`links` -> link_id, link_title, link_status

how could the data from the old database be converted into the new fields?

Thanks
-Tim

Fumigator
02-11-2010, 06:18 PM
If the columns in the two tables are identical data types, in identical order, you can omit the colum names when exporting the data. If you're using phpMyAdmin just uncheck "complete inserts"; if you're using mysqldump directly, leave off the --complete-insert parameter.

Old Pedant
02-11-2010, 09:39 PM
If you have both databases on the same server, you can do it all in a single SQL statement.


INSERT INTO newdb.links ( link_id, link_title, link_status )
SELECT linkid, linktitle, linkstatus FROM olddb.links;

Done.

Even if they are different servers, if the two servers are set up so that they can talk to each other you can do that.