1

在使用以下查询时(基于 Microsoft SQL 格式指南,因为我是 Access 新手,但对 SQL 有经验)我收到错误:

SELECT SW.USGS_NO, Q.SampleDate
FROM SW_PROPERTIES SW 
Inner Join (Locations L 
Inner join [(]Sample_Point P [
Inner Join [(]T_TestEvents E [
Inner Join [(]T_WQData Q )]
on E.TestEvent=Q.TestEvent)]
on P.SamplePnt=E.SamplePnt)]
on L.LocationPnt=P.LocationPnt)
on SW.SiteID=L.LocationPnt

错误很简单:

“FROM 子句中的语法错误。”

关闭错误后,“[(]SamplePoint P [”中的重命名或最终“P”将突出显示。

我知道表之间的链接是有效的,我只想要最高和最低表中的数据。我错过了什么?

4

2 回答 2

1

尝试这个

SELECT SW.USGS_NO, Q.SampleDate
FROM ((([SW_PROPERTIES] SW 
Inner Join ([Locations] L 
Inner join [Sample_Point] P 
Inner Join [T_TestEvents] E 
Inner Join [T_WQData] Q
on E.TestEvent=Q.TestEvent)
on P.SamplePnt=E.SamplePnt)
on L.LocationPnt=P.LocationPnt)
on SW.SiteID=L.LocationPnt
于 2015-11-26T13:13:49.363 回答
0

方括号的意义是什么?

我删除了它们,并且由于您只是使用 INNER JOIN,因此您甚至不需要括号。尝试这个:

SELECT 
    SW.USGS_NO, 
    Q.SampleDate

FROM SW_PROPERTIES SW 
Inner Join Locations L 
    on SW.SiteID=L.LocationPnt
Inner join Sample_Point P
    on L.LocationPnt=P.LocationPnt
Inner Join T_TestEvents E
    on P.SamplePnt=E.SamplePnt
Inner Join T_WQData Q 
    on E.TestEvent=Q.TestEvent
于 2013-04-03T17:19:49.130 回答