使用VBA,我希望根据某些条件将一个表的选择连接到另一个表。解决方法可能很简单,但是我找不到错误。我收到运行时错误-2147217900(80040e14)“联接操作中的语法错误”。
SELECT *
FROM [target$] AS Ziel
LEFT JOIN
(
SELECT *
FROM [source$]
WHERE [Zust].[FS] = 3
AND Year([Zust].[DATUM_1A])=2018 as Zust)
ON (
[Ziel].[Lage] = [Zust].[LAGE]
AND ((
[Zust].[BKM] < [Zust].[VKM]
AND [Ziel].[MitteBetrKm] <= [Zust].[VKM]
AND [Ziel].[MitteBetrKm] > [Zust].[BKM])
OR (
[Zust].[BKM] > [Zust].[VKM]
AND [Ziel].[MitteBetrKm] >= [Zust].[VKM]
AND [Ziel].[MitteBetrKm] < [Zust].[BKM])))
WHERE [Ziel].[MitteBetrKm] IS NOT NULL
ORDER BY [Ziel].[VonKm]