Move mysql colum to another table

Reply

Join Date: Aug 2006
Posts: 58
Reputation: desiguru is an unknown quantity at this point 
Solved Threads: 1
desiguru desiguru is offline Offline
Junior Poster in Training

Move mysql colum to another table

 
0
  #1
Jan 28th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 79
Reputation: varmadba is an unknown quantity at this point 
Solved Threads: 8
varmadba varmadba is offline Offline
Junior Poster in Training

Re: Move mysql colum to another table

 
0
  #2
Feb 3rd, 2009
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
:- 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/
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 58
Reputation: desiguru is an unknown quantity at this point 
Solved Threads: 1
desiguru desiguru is offline Offline
Junior Poster in Training

Re: Move mysql colum to another table

 
0
  #3
Feb 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Move mysql colum to another table

 
0
  #4
Feb 4th, 2009
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,
  1. UPDATE table_2,table_1 SET table_2.id=table_1.id WHERE table_1.counter = table_2.counter
This will update table_2's id column with id values of table_1.
Then delete the column "id" from table_1.
Cheers,
Nav
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC