Search code examples
javasqlms-accessms-access-2003jdbc-odbc

ODBC MS Access: syntax error in FROM clause


Working with Access 2003 & Java 1.7.0._45 in Windows Vista

When executing the following SQL query:

String myQuery = SELECT Table1.name, Table2.name FROM Table1 JOIN Table2 ON Table1.code = Table2.code WHERE Table1.name = 'Whatever'
ResultSet rs = stmt.executeQuery(myQuery);

I get a SQL exception due to syntax error in FROM clause:

java.sql.SQLException: [Microsoft][Controlador ODBC Microsoft Access] Error de sintaxis en la clausula FROM.

I've tried to run the same JOIN query in MySQL (with mysql client console, not with Java) and it works just fine, selecting the expected values.

It's there something special about the syntax when working with jdbc-odbc?


Solution

  • Error de sintaxis en la clausula FROM

    Access SQL does not support an unqualified JOIN keyword. Use INNER JOIN instead.