I have two tables with similar data, and I need to query the union of the tables. I have changed the actual table names I'm using to only illustrate the issue:
SELECT
UORD.ORDER_NUM
FROM
(SELECT ORDER_ID, ORDER_NUM, PKG_ID
FROM ORDER
UNION ALL
SELECT ORDER_ID, ORDER_NUM, PKG_ID
FROM AMENDING_ORDER) UORD
INNER JOIN PLAN ON PLAN.PKG_ID = UORD.PKG_ID;
I get
ORA-00918: column ambiguously defined
error due to the INNER JOIN
on PKG_ID
.
My actual query has several more joins on Order items, initially I started by using just the first table, e.g. ORDER
, which worked fine.
Is there any way this union of tables can be defined in query so it is not ambiguous?