MS Access LEFT JOIN SQL-syntax error
Read the MS Access documentation to learn how to do a LEFT JOIN sql operation. Been staring at my query now for one hour without being able to spot the problem.
SELECT gen_id_id
FROM ES_issue_table
LEFT JOIN __MOTHER_ISSUE_TABLE_6
ON ES_issue_table.issue_id = __MOTHER_ISSUE_TABLE_6.issue_id
This gives me the error:
java.sql.SQLException: [Microsoft][Drivrutin f?r ODBC Microsoft Access] Syntaxfel i fr?geuttrycket 'ES_issue_table.issue_id = __MOTHER_ISSUE_TABLE_6.issue_id'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.exe开发者_JAVA百科cuteQuery(Unknown Source)
at daos.MdbDao.testQuery(MdbDao.java:146)
at MdbDaoTest.testingQueries(MdbDaoTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The table name __MOTHER_ISSUE_TABLE_6
is not a valid table correlation name because of the leading underscore characters. Try an alternative -- preferably shorter! -- table correlation name e.g.
SELECT *
FROM ES_issue_table AS E1
LEFT JOIN __MOTHER_ISSUE_TABLE_6 AS M6
ON E1.issue_id = M6.issue_id;
If you are really fond of using your long table names then escape using square brackets i.e.
SELECT *
FROM ES_issue_table
LEFT JOIN __MOTHER_ISSUE_TABLE_6
ON ES_issue_table.issue_id = [__MOTHER_ISSUE_TABLE_6].issue_id;
Check that the issue_id
field in ES_issue_table
and the issue_id
field in __MOTHER_ISSUE_TABLE_6
are the same data type (for example both Numbers or both Text)
精彩评论