使用以下查询(基于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”突出显示。
我知道表之间的链接是有效的,我只想要来自最高和最低表的数据。我错过了什么?
答案 0 :(得分: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
答案 1 :(得分: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