Jump to content

Logic quetsion?


divadiva

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.