我在這個特定的語句上不斷收到語法錯誤。訪問內部連接的問題
SELECT tbl1.ProjectID, tbl1.EntryDate AS StartDate, tbl2.EntryDate AS EndDate,
(tbl3.ChecklistDayMax - tbl3.ChecklistDayMin + 1) AS DaysAllotted,
(SELECT ProjectPriority FROM project_master WHERE ProjectID = tbl1.ProjectID) AS Priority,
tbl3.MilestoneName,
IIF(Priority = 1, tbl3.BonusDaysFH,
IIF(Priority = 2, tbl3.BonusDaysFM,
IIF(Priority = 3, tbl3.BonusDaysFL))) AS BonusDaysAllotted
FROM (((checklist_entries AS tbl1
INNER JOIN checklist_entries AS tbl2 ON tbl1.ProjectID = tbl2.ProjectID)
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = milestone_def.MilestoneDefID)
INNER JOIN project_active_status AS tbl4 ON tbl1.ProjectID = project_active_status.ProjectID)
WHERE tbl1.ChecklistDay = tbl3.ChecklistDayMin
AND tbl2.ChecklistDay = tbl3.ChecklistDayMax
AND tbl4.ProjectIsOpen = FALSE;
錯誤說語法錯誤在加入操作,然後milestone_def凸顯了第二INNER JOIN之後。有趣的是,如果我轉這條線......
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = milestone_def.MilestoneDefID)
這條線......
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = tbl3.MilestoneDefID)
我得到的錯誤加入不支持表達,然後它突出...
[@milestoneID] = tbl3.MilestoneDefID)
但你可以看到,在第一個加入...
INNER JOIN checklist_entries AS tbl2 ON tbl1.ProjectID = tbl2.ProjectID
我把它命名爲tbl2,然後使用tbl2.ProjectID,表達式工作得很好。最終,我需要得到這個工作,不管我如何命名這些東西。
[@milestoneID]是傳遞到查詢匹配milestone_def.MilestoneDefID
問題標題「太大聲」。 – Lion
什麼是'[@milestoneID]'它是從一個表中取出來的?它是從哪裏來的?嘗試在該列之前放置正確的表別名,然後對連接中的另一列使用'tbl3.MilestoneDefID'。 – Taryn
這是一個傳遞給查詢的參數。 –