I’m trying to join two tables but can’t get the SQL right. My SQL statement is far more complex than the below SQL but the below SQL will do to show the principle. I get an invalid identifier exception when trying to refer to t or p. How come I cannot refer to these? I’m using Oracle DB.
SQL:
SELECT * FROM ((SELECT * FROM transactions t) FULL JOIN (SELECT * FROM payments p) ON (t.id = p.trans_id));
Exception:
Caused by: java.sql.SQLException: ORA-00904: "P"."TRANS_ID": invalid identifier
You are not really giving your querys an alias, you should do:
Of course, assuming that you are using real derived tables instead of those simple
SELECTs, otherwise you should just use the tables directly.