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

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -