I'm doing a beginners course on SQL and databases, and I'm trying to write a select statement that will join two tables on Oracle Apex. I'm using join...on... to do so. The two tables each have a column named the same, with the columns filled with matching values. Obviously, they tables need to join where the values match in each column. Here's the code:
select TRANSACTION_ID, BUYER_ID, FIRST_NAME from TRANSACTIONS join BUYER on TRANSACTIONS.BUYER_ID = BUYER.BUYER_ID;
- The two Tables are named "TRANSACTIONS" and "BUYER".
- Both tables have a column named "BUYER_ID".
- Only the table "TRANSACTIONS" has a column named "LOT_ID", which is associated with the buyer ID
- Only the table "BUYER" has a column named "FIRST_NAME", which is associated with the buyer ID
So if I were to simply write,
on BUYER_ID = BUYER_ID;
as I understand that would return the error saying "Columns Ambiguously Defined". But even when I specify the tables, as in,
on TRANSACTIONS.BUYER_ID = BUYER.BUYER_ID;
I still get a "Columns Ambiguously Defined". I wondered if it was an issue with the two columns having to be presented with the same name, so I tried,
on TRANSACTIONS.BUYER_ID as "BUYER_ID1" = BUYER.BUYER_ID as "BUYER_ID2";
but then that returns "invalid relational operator".