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
https://forums.phpfreaks.com/topic/176793-duplicating-data-in-multiple-tables/
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

 

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.