How to use union to re-arrange query results?
I have following situation: 3 tables x, y, z. They have one column in common and one column different like this:
Table x Table y Table z
------------- --------------- ---------------
A a A 1 A I
B b B 2 B II
C c C 3 C III
-------------- ------------------ ----------------
After query, I like to arrange them like this:
x y z
-------------------------------------------------
A a 1 I
B b 2 II
C c 3 III
-------------------------------------------------
I thought this script:
select x.column1, x.column2 , null, null from table x union
select y.column1,null, y.column2, null from table y union
select z.column1, null, null, z.column2 from table z