MS Access LEFT JOIN SQL 语法错误

发布于 2024-10-20 00:52:49 字数 2719 浏览 1 评论 0原文

阅读 MS Access 文档来了解如何执行 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)

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.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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不可一世的女人 2024-10-27 00:52:49

由于前导下划线字符,表名称 __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;

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;
层林尽染 2024-10-27 00:52:49

检查 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文