'How can i join same tablet in mysql?

I have 3 tables:

Table1:

Myid     description
P         Pera
M         Mela

Table2:

Myid     description
B         Banana
C         Ciliegia

Table3:

Myid     description
N        Noce
Z        Zenzero

I need this result order by Myid

Table    MyId  Description
Table2   B     Banana
Table2   C     Ciliegia
Table1   M     Mela
Table3   N     Noce
Table1   P     Pera
Table3   Z     Zenzero

Is it possible?

Br,Alessandro



Solution 1:[1]

You can do:

select 'Table1' as `table`, Table1.* from Table1
union all select 'Table2', Table2.* from Table2
union all select 'Table3', Table3.* from Table3
order by description

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1