参数问题

时间:2012-10-03 19:36:40

标签: sql parameters

感谢您的支持,了解以下代码的错误:

SELECT [Name] As Milestone, [Start], [Outgoing tasks] As OTask 
FROM [Sheet1$] 
WHERE [Main project] = 'Company A' AND [Main link] = 'Project 1' 
AND [Task class] = 'Company' 
AND [Start] > (SELECT [Start] 
               FROM [Sheet1$] 
               WHERE [Main project] = 'Company A' 
               AND [Main link] = 'Project 1' 
               AND [Name] = OTask 
               AND [Incoming tasks] = Milestone)

我实际上要做的是获取在其后继(Name)之后发生的注册表(Outgoing tasks)。

我的参数(Milestone和OTask)是否存在问题?

ERROR: NO VALUE GIVEN FOR ONE OR MORE REQUIRED PARAMETERS

感谢!!!

1 个答案:

答案 0 :(得分:2)

问题是你在where where条件下使用你的别名。

它应该是这样的

SELECT [Name] As Milestone, [Start], [Outgoing tasks] As OTask 
FROM [Sheet1$] 
WHERE [Main project] = 'Company A' AND [Main link] = 'Project 1' 
AND [Task class] = 'Company' 
AND [Start] > (SELECT [Start] 
               FROM [Sheet1$] 
               WHERE [Main project] = 'Company A' 
               AND [Main link] = 'Project 1' 
               AND [Name] = [Outgoing tasks]
               AND [Incoming tasks] = [Name])

您必须将OTask替换为[Outgoing tasks]而将Milestone替换为[Name]