mysql - Inserting the same fields from multiple tables (in a more efficient way) -


i'm looking avoid rewriting same queries below (for each unique table):

insert dbo.databasenew (field1 , field 2) select field 1, field 2  olddatabase.dbo.[table 1] description 'something';  insert dbo.databasenew (field1 , field 2) select field 1, field 2  olddatabase.dbo.[table 2] description 'something'; 

i've tried combining queries below, doesn't work:

insert dbo.databasenew (field1 , field 2) select field 1, field 2  olddatabase.dbo.[table 1], olddatabase.dbo.[table 2] description 'something'; 

any help? sorry noob question. thanks!

you use union operator

insert dbo.databasenew (field1 , field2) ( select field1, field2  olddatabase.dbo.[table 1] description 'something' union select field1, field2  olddatabase.dbo.[table 2] description 'something' ); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -