Orion
Orion

Reputation: 33

MySQL View with two columns imported into one

My problem appears easy to solve, but I can't achieve it alone.

I have a MySQL db with 3 tables: data_A ; data_B ; data_C.

Table data_A has a column called A_path
... data_B a column called B_path
and data_C a column called C_path.

And I want to create a view with 2 columns: data_type and data_path.

If data came from data_A, data_type value will be A, idem for B and C and in the data_path column, the X_path value from the tables.

Which command can do that in order to create the view please? I've already search on the net, and I've found similar posts but nothing works in my case.

Upvotes: 0

Views: 24

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269773

I think you want union all:

select 'A' as data_type, A_path as data_path from a union all
select 'B' as data_type, B_path as data_path from b union all
select 'C' as data_type, C_path as data_path from c ;

Upvotes: 0

Related Questions