阅读MS Access documentation以了解如何进行LEFT JOIN sql操作。现在盯着我的查询一小时而不能发现问题。
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
这给了我错误:
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.executeQuery(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)
答案 0 :(得分:2)
由于前导下划线字符,表名__MOTHER_ISSUE_TABLE_6
不是有效的表相关名。尝试替代方案 - 最好更短! - 表相关名称,例如
SELECT *
FROM ES_issue_table AS E1
LEFT JOIN __MOTHER_ISSUE_TABLE_6 AS M6
ON E1.issue_id = M6.issue_id;
如果您真的喜欢使用长表名,那么请使用方括号转义,即
SELECT *
FROM ES_issue_table
LEFT JOIN __MOTHER_ISSUE_TABLE_6
ON ES_issue_table.issue_id = [__MOTHER_ISSUE_TABLE_6].issue_id;
答案 1 :(得分:0)
检查issue_id
中的ES_issue_table
字段和issue_id
中的__MOTHER_ISSUE_TABLE_6
字段是否为相同的数据类型(例如数字或文字)