本文介绍了SQL语法错误-JOIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试消除不必要的重复查询结果.要点是,[CUSIP]字段存在于所有相关表中,但是,[4DTYR]字段存在于除[IDX_FS]之外的所有表中.

I am attempting to eliminate unwanted duplicate query results. The gist is that the field [CUSIP] exists in all tables in question, however, the field [4DTYR] exists in all tables except [IDX_FS].

我以前只通过[CUSIP]字段加入表,这导致查询产生了不必要的重复结果(某种形式的[4DTYR]排列是从包含该字段的所有表中得出的).

I had previously only joined the tables via the [CUSIP] field, and that resulted in the query produced unwanted duplicate results (some sort of a permutation of [4DTYR] from all the tables that contained that field).

然后,我在下面进行了修改.但是,现在我收到一个JOIN语法错误.任何人都可以帮忙吗?我已转贴了此Q以防万一.谢谢!

Then, I made the modification below. However, now I'm receiving a JOIN syntax error. Can anyone kindly help? I've reposted just in case this Q got a little bit stale. Thanks!

FROM

(((IDX_FS LEFT JOIN DATA_BS
  ON IDX_FS.CUSIP = DATA_BS.CUSIP)

LEFT JOIN DATA_Footnotes
  ON IDX_FS.CUSIP = DATA_Footnotes.CUSIP)

LEFT JOIN DATA_IS
  ON IDX_FS.CUSIP = DATA_IS.CUSIP)

LEFT JOIN DATA_SP
  ON IDX_FS.CUSIP = DATA_SP.CUSIP

AND (((DATA_BS LEFT JOIN DATA_IS
  ON DATA_BS.CUSIP = DATA_IS.CUSIP
     AND DATA_BS.4DTYR = DATA_IS.4DTYR)

LEFT JOIN DATA_SP
  ON DATA_BS.CUSIP = DATA_SP.CUSIP
     AND DATA_BS.4DTYR = DATA_SP.4DTYR)

LEFT JOIN DATA_Footnotes.4DTYR
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
     AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR

推荐答案

似乎您的错误在这里

LEFT JOIN DATA_Footnotes.4DTYR -- this is not a valid table name
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
   AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR

删除.4DTYR应该可以解决您的错误

removing the .4DTYR should fix your error

LEFT JOIN DATA_Footnotes
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
   AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR

这篇关于SQL语法错误-JOIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 07:51