cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

UNION ALL query for two tables, unmatching column names. Need Help.

Anonymous
Not applicable

Hi All,

I am trying to do a UNION ALL command with two tables where one table has a few column names that do not match the other table so I am using AS for an alias to match the column names. I am still having trouble getting the two tables to UNION properly considering the column order and names are matched. Please see below example:

SELECT name, address, location, city

FROM Database.table1

UNION ALL

SELECT platform AS name, address, spot AS location, NULL AS city

FROM Database.table2;

The reason I am doing this is that table 2 are values that didnt join into table 1, so I am adding them into table 1 through a union.

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group