Bendude14 Posted October 7, 2009 Share Posted October 7, 2009 I have three tables which build information about one House, could someone please share some ideas on what would be the easiest way to duplicate a house and all its information in all three tables. I know I can execute 3 select statements get all the information I need then insert the new house, select its new unique ID and then insert the rest of the information into the last two tables with the correct ID. I just can't help but think this is a long way round? Maybe there is a SQL way with a temp table which would be more effective, if so I'm sorry for posting this in the wrong forum. Thanks Ben Quote Link to comment Share on other sites More sharing options...
fooDigi Posted October 7, 2009 Share Posted October 7, 2009 well, maybe a master house table, which contains the current tables id (if you have any)... that way you can associate them and create many... but more info and sample data may be nice... Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 7, 2009 Author Share Posted October 7, 2009 tableOne ========== tblOneID Name Value tableTwo ========= tblTwoID ImageUrl Name tblOneID tableThree ========== tblThreeID Name Value tblOneID Ok so above is what the three tables are like and what I need to is duplicate a row in each table, obviously all data is related via "tblOneID" I retrieve the ID from my app for the record to duplicate but once I have duplicated the row in tableOne I need to use the newly generated ID (Its using autoincrement) to duplicate the data in tableTwo and tableThree tableTwo and tableThree may have mulitple records related to the record in tableOne and all Records would need to be duplicated. Make sense? Thanks Ben Quote Link to comment Share on other sites More sharing options...
fooDigi Posted October 7, 2009 Share Posted October 7, 2009 maybe look into innodb and cascading.... Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 7, 2009 Author Share Posted October 7, 2009 hmm I don't think that is what I am after if you are talking about Cascade delete and Cascade Update? I only want to perform this duplication sometimes, not every time I access the database via update etc Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 8, 2009 Author Share Posted October 8, 2009 I don't like to bump topics but I would like some more suggestions on this topic and It's already dropped of to page 3. Kind Regards Ben Quote Link to comment 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.