solved Moving data between tables with different field names
Posted: Mon Apr 14, 2008 11:54 am
Hi All
I need to move some legacy data (around 350K rows) from a single table to a series of new tables based on an ID in the legacy table. The thing is, the new tables have a different schema.
Is there any quick way that I can move the data across, or am I stuck with reading in row by row from the old table and inserting row by row into the new tables?
I was hoping something like this:
could be looped over for each of the new tables and the data moved across, but I'm wrong (or at least its not working for me).
Could anyone suggest anything or am I stuck?
Thanks for reading, and hopefully for replying
I need to move some legacy data (around 350K rows) from a single table to a series of new tables based on an ID in the legacy table. The thing is, the new tables have a different schema.
Is there any quick way that I can move the data across, or am I stuck with reading in row by row from the old table and inserting row by row into the new tables?
I was hoping something like this:
Code: Select all
for ($result->first(); !$result->end(); $result->next()){
$table = $result->table_id;
$id = $result->id;
$sql = "INSERT INTO `$table` SELECT
DateTime AS date,
RecipientEmail AS email_address,
RecipientID AS recipient_id,
BounceType AS bounce_type,
BounceText AS detail,
ListUpdated AS list_updated
WHERE ID = '$id';";
$db->query($sql);
}
Could anyone suggest anything or am I stuck?
Thanks for reading, and hopefully for replying