MS Access Query - 使用参数值作为选定记录之一

时间:2011-10-12 11:19:25

标签: ms-access select parameters

我正在编写带参数的MS Access查询,并想知道是否可以将其中一个参数包含为返回的选定记录:

PARAMETERS [@SubmissionID] IEEEDouble, [@StartDate] DATETIME, [@EndDate] DATETIME;
INSERT INTO tblHUD_client_profile
(SubmissionID, ClientID)
SELECT [@SubmissionID] as SubmissionID, DISTINCT(ClientID) 
FROM tblClientEducation
WHERE (BeginDate BETWEEN [@StartDate] AND [@EndDate]
   OR EndDate BETWEEN [@StartDate] AND [@EndDate])
   AND NOT EXISTS(
                  Select ClientID 
                  from tblHUD_client_profile 
                  WHERE SubmissionID = [@SubmissionID] 
                  AND ClientID = tblClientEducation.ClientID
                  );

“选择[@SubmissionID]作为SubmissionID”总是给我一个语法错误。

如果有关于此解决方案的问题,我道歉。我环顾四周,但是有很多关于MS Access查询和参数的基本问题,我找不到我想要的东西。

2 个答案:

答案 0 :(得分:1)

为MS Access留下@:

PARAMETERS SubmissionID Integer;
SELECT [SubmissionID] as SubmissionID, DISTINCT(ClientID) 
FROM tblClientEducation

答案 1 :(得分:0)

在查看原始代码后,它似乎按预期工作。