Jump to content

Duplicating Data in Multiple Tables


Bendude14

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
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.