0

我使用以下代码在 DAO 中查询我的数据库,效果很好:

SELECT * 
FROM (Resources LEFT JOIN [Select * FROM AvailabilityBlocks LEFT JOIN Location ON AvailabilityBlocks.LocationID=Location.LocationID WHERE ((CStr(AvailabilityBlocks.LocationID) IN ('8', '14', '16', '1', '15', '17', '10', '9', '19', '12', '5', '18', '13', '20', '3', '26', '2', '25', '28', '27') AND (AvailabilityBlocks.Type = 3 OR AvailabilityBlocks.Type = 4)) OR AvailabilityBlocks.Type = 2) AND Begin < #15-Jul-2013 12:00:00 AM# And Begin >= #08-Jul-2013 12:00:00 AM#]. AS FilteredTable ON Resources.ResourceID=FilteredTable.ResourceID) LEFT JOIN EmployeeTypes ON EmployeeTypes.TypeID=Resources.EmployeeType ORDER BY RClass, Resources.LastName ASC, Resources.FirstName ASC, Resources.ResourceID ASC, AvailabilityBlocks.Begin ASC, AvailabilityBlocks.End Desc, Location.SubType DESC

然后我将所有代码转换为 ADO,SQL 停止工作,现在显示

FROM 子句中的语法错误。

错误信息!

任何帮助,将不胜感激!

4

1 回答 1

0

尝试这个。我认为您关闭派生表(“FilteredTable”)的方式已关闭。还。您可能想尝试使用表别名...

SELECT * 
FROM 
Resources res 
LEFT JOIN (
[Select * FROM AvailabilityBlocks avb LEFT JOIN Location loc ON avb.locID=loc.locID 
WHERE ((CStr(avb.locID) IN ('8', '14', '16', '1', '15', '17', '10', '9', '19', '12', '5', '18', '13', '20', '3', '26', '2', '25', '28', '27') 
AND (avb.Type = 3 OR avb.Type = 4)) OR avb.Type = 2) 
AND Begin < #15-Jul-2013 12:00:00 AM# And Begin >= #08-Jul-2013 12:00:00 AM#] ) AS FilteredTable 
ON res.ResourceID=FilteredTable.ResourceID) 

LEFT JOIN EmployeeTypes ON EmployeeTypes.TypeID=res.EmployeeType 

ORDER BY RClass, res.LastName ASC, res.FirstName ASC, res.ResourceID ASC, avb.Begin ASC, avb.End Desc, loc.SubType DESC
于 2013-07-08T18:59:45.927 回答