| | |
Move mysql colum to another table
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2006
Posts: 58
Reputation:
Solved Threads: 1
I have a column "ID" in a table, and I need to move that to another table in the same database. How do I do this?
--
Share files up to 1Gb - FileOP.com
Share files up to 1Gb - FileOP.com
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Solved Threads: 8
Create ID column in second table
and run a update query on second table with joining both the tables,so all values in ID column will be update in second table properly
come back and drop column in the first table
and run a update query on second table with joining both the tables,so all values in ID column will be update in second table properly
come back and drop column in the first table
:- Varma
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
•
•
Join Date: Aug 2006
Posts: 58
Reputation:
Solved Threads: 1
Sorry how do you update only one column?
Last edited by desiguru; Feb 3rd, 2009 at 6:23 am.
--
Share files up to 1Gb - FileOP.com
Share files up to 1Gb - FileOP.com
If you want to 'move' a column from one table to another table, both the tables should have a common column to link these 2 tables. First, as Vermadba has mentioned, you have to create a column called "id" in table_2 first. Then, update the second table's "id" column using joins.
For example,
This will update table_2's id column with id values of table_1.
Then delete the column "id" from table_1.
Cheers,
Nav
For example,
mysql Syntax (Toggle Plain Text)
UPDATE table_2,table_1 SET table_2.id=table_1.id WHERE table_1.counter = table_2.counter
Then delete the column "id" from table_1.
Cheers,
Nav
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the MySQL Forum
- Previous Thread: What query do i need???
- Next Thread: need help, please!
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm data database design developer development distinct drupal dui ec2 email enter enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword kickfire laptop legal license licensing linux maintenance mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird virtualization






