这个查询
SELECT P2.ID, P2.Storenum, [Periods_2013-2014].[PeriodDate] AS [OpenFromDate],
P2.[Open From Day], P2.[Open From Time], P2.[Open To Day],
P2.[Open To Time]
FROM [Periods_2013-2014]
INNER JOIN [tblOpenCloseTimes] AS P2 ON [Periods_2013-2014].[Day]=P2.[Open From Day]
WHERE ((([Periods_2013-2014].Day)=P2.[Open From Day]
AND P2.Storenum ="43010605"
AND [Periods_2013-2014].Period = "4"))
导致“输入参数值”Query1.PeriodDate
作为请求的参数,而如果我只是AS [OpenFromDate]
从第一行中删除“”,则查询运行完美。[Periods_2013-2014]
如果我将表别名为 P1 ,它的作用相同。PeriodDate
除了我需要堆叠查询以获取该字段两次之外,这不会是一个问题。我究竟做错了什么?
更新:这个查询
SELECT T2.Storenum, T2.[PeriodDate] AS [Open From Date], T2.[Open From Day],
T2.[Open From Time], T1.[PeriodDate] AS [Open To Date], T2.[Open To Day],
T2.[Open To Time]
FROM [Periods_2013-2014] AS T1,
(SELECT P2.Storenum, P1.[PeriodDate], P2.[Open From Day], P2.[Open From Time],
P2.[Open To Day], P2.[Open To Time]
FROM [Periods_2013-2014] AS P1 INNER JOIN tblOpenCloseTimes AS P2
ON P1.[Day]=P2.[Open From Day]
WHERE (((P1.Day)=P2.[Open From Day]
AND P2.Storenum ="43010605"
AND P1.Period = "4"))
ORDER BY P1.[PeriodDate]) AS T2
WHERE T1.[Day]=T2.[Open To Day]
AND T1.[PeriodDate]>=T2.[PeriodDate]
AND T1.[PeriodDate] - T2.[PeriodDate] <7
ORDER BY P1.[PeriodDate];
现在我已经从属性表中删除了 Order By 子句,现在工作得很好。