<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UNION ALL query for two tables, unmatching column names. Need Help. in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/union-all-query-for-two-tables-unmatching-column-names-need-help/m-p/3862#M760</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT name, address, location, city&lt;/P&gt;&lt;P&gt;FROM Database.table1&lt;/P&gt;&lt;P&gt;UNION ALL&lt;/P&gt;&lt;P&gt;SELECT platform AS name, address, spot AS location, NULL AS city&lt;/P&gt;&lt;P&gt;FROM Database.table2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2023 20:05:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-05-30T20:05:03Z</dc:date>
    <item>
      <title>UNION ALL query for two tables, unmatching column names. Need Help.</title>
      <link>https://community.databricks.com/t5/data-engineering/union-all-query-for-two-tables-unmatching-column-names-need-help/m-p/3862#M760</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT name, address, location, city&lt;/P&gt;&lt;P&gt;FROM Database.table1&lt;/P&gt;&lt;P&gt;UNION ALL&lt;/P&gt;&lt;P&gt;SELECT platform AS name, address, spot AS location, NULL AS city&lt;/P&gt;&lt;P&gt;FROM Database.table2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 20:05:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/union-all-query-for-two-tables-unmatching-column-names-need-help/m-p/3862#M760</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-30T20:05:03Z</dc:date>
    </item>
  </channel>
</rss>

