If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Complex Insert problems.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-09-09, 17:30
spyker spyker is offline
Registered User
 
Join Date: May 2009
Posts: 1
Complex Insert problems.

Hi,

I am trying to get quite a complex insert to work, im not sure if its even feasible. We have about 35 tables but ill just put an example down below then ill explain what needs doing.

+-------------------------------+
|---------duties----------|
+-----+----+---------+----------+
|ID|Title|models_ID|
+-----+----+---------+----------+

+--------------------------+
|---------dutieusers---------|
+----------+----+-----+----+
|duties_ID|users_ID|models_ID|
+----------+----+-----+----+

Basically what we(my team, 2nd year comp sci group) are trying to do is duplicate the data in the tables changing the models_ID to a new value. The whole system works on a year by year basis and the clients want to duplicate the data year on year, which is what the models_ID represents. This is fine, importing like that is ok. Now where our problem lies is that when we duplicate the duties data, changing the models_ID to the new one we also change its ID as this is set as auto increment. Now as dutieusers relies on this in its table when we duplicate all the dutieusers the duties_ID match up to the old duties.

We cannot figure out how to do the import and keep those ID's matched up. Our current approach is to loop through all the data in PHP as objects using nested for each loops and so we have direct access to them. This is painfully slow with plenty of data and all the tables as well as a memory hog. Any help will be appreciated. Thanks,

Spyker
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On