0

I am facing following issue:

I had Tables

  1. A with columns: [ID, Name]
  2. B with columns: [ID, Name]

Now I want to UNION those two table with the Table result C:

C with columns [ID, Name, Source]

The Source column in Table C will shows value "A" or "B" to illustrate the source of that line is from Table A or B.

I tried some guides with

(SELECT *, "A" AS SOURCE FROM A) UNION ALL (SELECT *, "B" AS SOURCE FROM B)

But It still seems wrong!

Note: This is for SAP HANA. How I can do now ?

ThuanNguyen
  • 169
  • 1
  • 2
  • 13
  • In production code you should explicitly select the columns which you want to see in the result. This makes your query more robust against changes of the underlying tables (additional columns, changing order of column). – Christoph G Jan 19 '17 at 20:02

1 Answers1

1

The problem with your query is the you used double quotes instead of single quotes for the content of the source column.

Please change your query to:

(SELECT *, 'A' AS SOURCE FROM A) UNION ALL (SELECT *, 'B' AS SOURCE FROM B)

Then it should work