views:

47

answers:

1

i have same table at my local database and at my live-main database. I have to copy the content of a particular column from local to main not the whole table.How can i do that in mysql???

+2  A: 

Run on your local machine

mysql the_schema -e "CREATE TABLE __data__ SELECT id, the_column FROM the_table" 
mysqldump the_schema __data__ > data.sql
mysql the_schema -e "DROP TABLE __data__"

Copy the sql file to the production db and run the following:

cat data.sql | mysql the_schema
mysql the_schema -e "UPDATE TABLE the_table, __data__ SET the_table.the_column=__data__.the_column WHERE the_table.id=__data__.id"
mysql the_schema -e "DROP TABLE __data__"
David Rabinowitz