UNION
Joins two tables, and expands vertically. It adds more rows, not columns.
Note:
- that union gets rid of duplicates by default
- Column naming matches that of the first select, the second select columns will go into the columns of the same position. AKA
SomeWeirdNamewill go into theColName1column
SELECT Tb1.ColName1,
Tb1.ColName2,
Tb1.ColName3,
Tb1.ColName4
FROM SchemaName.TableName1 AS Tb1
UNION
SELECT Tb2.SomeWeirdName,
Tb2.ColName2,
Tb2.ColName3,
Tb2.ColName4
FROM SchemaName.TableName2 AS Tb2
Enable Duplicates
SELECT Tb1.ColName1,
Tb1.ColName2,
Tb1.ColName3,
Tb1.ColName4
FROM SchemaName.TableName1 AS Tb1
UNION ALL
SELECT Tb1.ColName1,
Tb1.ColName2,
Tb1.ColName3,
Tb1.ColName4
FROM SchemaName.TableName1 AS Tb1