divadiva Posted January 7, 2009 Share Posted January 7, 2009 Experts, Can you please help me with this issue.The website contains tool_id.Now ,all I want to do is to create a new fields Updatestool_id and store the orignal in them and store the new one in the tool_id. Current Scenario: tool_id(currently hold thousands of id) updated tool_id (yet to create) In short this is what I want: tool_id= updated tool_id Updatedtool_id = list that is there in the system. Is it doable?How will I transfer the huge amount of data in database? Best Regards, Divya Quote Link to comment https://forums.phpfreaks.com/topic/139883-logic-quetsion/ Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 Not hard at all really. As long as you have the new tool_id handy... First I would manually alter the table and add updatestool_id via phpMyAdmin or another means. Then you can run this code on php (note I do not know how you are getting the new id, so yea this is loosely based: mysql_query("UPDATE tools SET updatetool_id = `tool_id`, tool_id = " . $newToolId . " WHERE tool_id = " . $oldToolId); That should do the trick, I am not sure so I would try this on a test DB before testing it on the production database. Quote Link to comment https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731852 Share on other sites More sharing options...
l_kris06 Posted January 7, 2009 Share Posted January 7, 2009 UPDATE table_name SET column1 = column2; where table_name = current table that needs to be manipulated column1 = destination column2 = source; Careful : The above query will copy all that is in column1 to column2. Use the "WHERE" clause to do conditional update. Rgds, Kris Quote Link to comment https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731860 Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 UPDATE table_name SET column1 = column2; where table_name = current table that needs to be manipulated column1 = destination column2 = source; Careful : The above query will copy all that is in column1 to column2. Use the "WHERE" clause to do conditional update. Rgds, Kris This is probably better for the initial step. That way you have all the currentids in the updates column then you can manipulate the tool_id without worrying about if it copied right =) Quote Link to comment https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.