Table 1 :
X , Y , Z
10, 12, 14
20, 17, 18
Table 2:
X , Y, Z
100, 75, 80
375, 100, 122
I have 7 such tables. Expected outcome is combining only all rows. Which Join should I use?
Final Table
X , Y , Z
10, 12, 14
20, 17, 18
100, 75, 80
375, 100, 122
2
Answers
Check out SQL Union
https://www.w3schools.com/sql/sql_union.asp
This isn’t technically a join on common data, rather a way to combine the results from tables with the same schema (column definitions)
The query you need is to union together the result of each query:
You can remove
all
if you need to exclude any duplicate rows, but if you don’t keepunion all
as removing duplicates carries additional overhead.