Marco Frag Delle Monache
Marco Frag Delle Monache

Reputation: 1458

MySQL View to show rows from multiple columns in a single column

I need to create a MySQL View that allows me to show in a single columns all rows from different tables' columns.

For example: Table1:

  -----------------
  | name  |  desc |
  -----------------
1 | name1 | desc1 |
  -----------------

Table2:

  -----------------
  | name  |  desc |
  -----------------
1 | name2 | desc2 |
  -----------------

I would like to have a view that shows:

  ---------
  | name  | 
  ---------
1 | name1 |
2 | name2 |
  ---------

Is this possible? I only see people using concat() and I don't need this..

Upvotes: 1

Views: 199

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269753

Do you want union/union all?

select name
from table1
union all
select name
from table2;

Upvotes: 2

Related Questions