Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
table1:
tconst attr_a attr_b attr_c
table2:
tconst attr_d attr_e
What I want:
tconst attr_a attr_b attr_c attr_d attr_e
Note: The tconst in table1 and table2 are different numbers, no intersection
Could anyone help? Thanks!
You can try something like this, so that both statements in the union have the same number of columns:
union
select tconst , attr_a , attr_b , attr_c, null attr_d, null attr_e from table1 union all select tconst , null attr_a , null attr_b , null attr_c, attr_d, attr_e from table2
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.