Shafizadeh
Shafizadeh

Reputation: 10350

how to create a table made of two same tables with different content ?

I have two table: table1, table2. I need to mix them and then create a new table.

Here is my example:

// table1:
+------+------+
| col1 | col2 |
+------|------+
| 111  |  222 |
| 333  |  444 |
+------+------+

// table2:
+------+------+
| col1 | col2 |
+------|------+
| 555  |  666 |
| 777  |  888 |
+------+------+

So, I need something like this:

// new_table:
+------+------+
| col1 | col2 |
+------|------+
| 111  |  222 |
| 333  |  444 |
| 555  |  666 |
| 777  |  888 |
+------+------+

How can I do that ?

Upvotes: 0

Views: 28

Answers (2)

Sean Zhang
Sean Zhang

Reputation: 108

If you want to remove the same items, you can

create table new_table as
    select col1, col2 from table1
    union
    select col1, col2 from table2

Upvotes: 0

juergen d
juergen d

Reputation: 204854

use union

create table table3 as
    select col1, col2 from table1
    union all
    select col1, col2 from table2

Upvotes: 1

Related Questions