Thomas,
I got the error with the example. (see below)
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Column
MOVIES.TITLE not found; SQL statement:
SELECT M.title, M.rating, A.ACTOR
FROM MFE.MOVIES M, MFE.ACTORS A
WHERE MOVIES.title = ACTORS.title [42122-107]
I tried Oracle and I got similar error
Exception in thread "main" java.sql.SQLException: ORA-00904:
"ACTORS"."TITLE": invalid identifier
so evidently H2 behaves similar to Oracle and H2 is most probably
correct.
Still it feels strange that aliases turn off original table name in
the rest of the query. Are there options to change this behavior in
H2?
Thanks,
Pavel
=================================================================
public void join() throws Exception {
Connection h2;
Class.forName("org.h2.Driver");
h2 = DriverManager.getConnection("jdbc:h2:mem:");
Statement sa = h2.createStatement();
sa.execute("CREATE SCHEMA MFE");
sa.execute("CREATE TABLE MFE.MOVIES (TITLE CHAR(30), RATING
INT)");
sa.execute("CREATE TABLE MFE.ACTORS (TITLE CHAR(30), ACTOR CHAR
(30))");
// OK
ResultSet rs1 = sa.executeQuery(" SELECT M.title, M.rating,
A.ACTOR\n" +
"FROM MFE.MOVIES M, MFE.ACTORS A\n" +
"WHERE M.title = A.title ");
// FAILS
ResultSet rs2 = sa.executeQuery(" SELECT M.title, M.rating,
A.ACTOR\n" +
"FROM MFE.MOVIES M, MFE.ACTORS A\n" +
"WHERE MOVIES.title = ACTORS.title ");
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---