Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/139883-logic-quetsion/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731852
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731860
Share on other sites

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 =)

Link to comment
https://forums.phpfreaks.com/topic/139883-logic-quetsion/#findComment-731865
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.