MYSQL: Merge two tables into one, with union -


i have make table out of 2 other tables (and use union). query works is:

select * tabel1 union select * tabel2 

now have put result(data) table3 (a table have, same columns in table1 , table2).

who can me?

insert table3  select * tabel1 union select * tabel2 

since have same columns in 3 of them ...

in general case should work column lists like

insert table3 (col1, col2, col3) select col1, col2, col3 tabel1 union select col1, col2, col3 tabel2 

this way avoid trouble auto_increment id-columns. should consider using union all since union filters out duplicate lines , therefore take longer on large tables.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -