我使用以下代码在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子句中的语法错误。
错误消息!
任何帮助将不胜感激!
答案 0 :(得分: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