访问中的联合查询对于评估而言过于复杂

时间:2014-05-13 14:50:25

标签: sql database union

我在访问中遇到以下错误,我不知道为什么。我将其翻译成荷兰语:

"Deze expressie is niet correct getypt of te complex voor evaluatie.
Een numerieke expressie kan bijvoorbeeld te veel gecompliceerde elementen bevatten.
Probeer de expressie te vereenvoudigen door verschillende delen van de expressie toe te wijzen aan variabelen."

英文:

"This expression has a spelling error or is too complex for evaluation.
A numeric expression could contain to many complex elements.
Try to simplify the expression by assigning several parts to variables."

奇怪的是,我的查询单独进行。该错误仅发生在我使用UNION功能的那一刻。 既然他们单独工作我不认为这是打字错误?树查询是生成树的另一个查询。 (3个与id和arent id链接的表)

其他表格只是数据。

SELECT "(z) Opleidingen" AS Campaign, LCase([Tree query]![sector] & "#" & IIf([Tree query]![cluster] Is Null, [Tree query]![subsector],[Tree query]![cluster])& "$" & [Opleidingsnaam]![Collinaam]) AS Adgroup, "Broad" AS [Keyword Type], "0,60" AS [Max CPC], [Opleidingsnaam]![URL] AS [Destination URL], "+" & Replace([Opleidingsnaam]![Opleidingsnaam]," "," +") & " +" & Replace([Locatie]![Keyword]," "," +") AS Keyword, "Active" AS [Keyword Status], Opleidingsnaam.Timestamp AS t1, Locatie.Timestamp AS t2, Null AS t3, Null AS t4, Null AS t5
FROM Locatie, Opleidingsnaam INNER JOIN [Tree query] ON Opleidingsnaam.SectorId = [Tree query].ID
WHERE (((Opleidingsnaam.Timestamp)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Locatie.Timestamp)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Null)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Null)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Null)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate]));


UNION


SELECT "(z) Opleidingen" AS Campaign, LCase([Tree query]![sector] & "#" & IIf([Tree query]![cluster] Is Null,[Tree query]![subsector],[Tree query]![cluster])& "$" & [Opleidingsnaam]![Collinaam]) AS Adgroup, "Broad" AS [Keyword Type], "0,60" AS [Max CPC], [Opleidingsnaam]![URL] AS [Destination URL], "+" & Replace([Opleidingsnaam]![Opleidingsnaam]," "," +") & " +" & Replace([Campus]![Keyword]," "," +") AS Keyword, "Active" AS [Keyword Status], Opleidingsnaam.Timestamp AS t1, Campus.Timestamp AS t2, Null AS t3, Null AS t4, Null AS t5
FROM Campus, Opleidingsnaam INNER JOIN [Tree query] ON Opleidingsnaam.SectorId = [Tree query].ID
WHERE (((Opleidingsnaam.Timestamp)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Campus.Timestamp)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Null)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate])) OR (((Null)>[inputdate]) AND ((Opleidingsnaam.Startdatum)>[inputdate]));

请有人帮我解决这个问题。这让我抓狂:)

背景:我使用union查询来组合多个查询。查询组合了包含关键字的不同表。我想创建所有可能的关键字组合。这是我在Google Adwords中使用的。

提前致谢!

2 个答案:

答案 0 :(得分:1)

UNION查询不容易排除故障。我认为@GarethD是对的 - 给你最好的机会,你应该:

  1. 保存每个查询(仔细检查每个查询的字段数是否相同)
  2. 将您的UNION查询更改为SELECT * FROM Query1 UNION SELECT * FROM Query2...
  3. 没有连接,您使用的是笛卡尔积,它占用了大量内存。我怀疑即使这样也无法解决你的问题。如果这不起作用,您可能需要使用丑陋的黑客 - 循环遍历所有查询并将结果附加到临时表。

答案 1 :(得分:0)

我遇到了问题,并在select子句的末尾添加了',*'。它工作,但我注意到,由于某种原因它只添加了一个字段,用作底层查询中的WHERE标准。然后我删除了*并添加到那个字段中。嘿presto,一切正常。所以我的结论是需要包含基础WHERE字段。遗憾的是JET在每次发布时都不太可靠。