The error suggests there is an ON
in an unexpected place in your query, and as the query itself looks fine, my guess is the problem is with the way you construct the query in your Java application. There might be some whitespace missing in your query.
My guess is that you have something like
query = "SELECT * " +
"FROM table1" +
"JOIN table2 ON " //.....
The missing whitespace will make the SQL:
SELECT * FROM table1JOIN table2 ON ....
For the parser, this is perfectly valid until it encounters the ON
token, which triggers the error. Eg the parser identifies it is a SELECT
with *
(all) columns from table1JOIN
with alias table2
. During parsing the server doesn't check if the table actually exists, so it doesn't trip over the fact that table1JOIN
doesn't exist. That is checked after parsing is successfully completed.