如何阻止Access重新格式化并损坏我的子库 [英] How to stop Access from reformating and damaging my subquriries
问题描述
我写了很多年的SQL,但我很少使用Access。在Access 2003中,我编写了一个SQL查询,其子查询包含在括号中。我跑了它,它工作正常。尝试稍后运行查询时,我收到一条错误消息。似乎Access
尝试格式化我的查询,并在这样做时用括号替换括号并在子查询的末尾插入分号。不用说,查询没有运行。关于如何改变这种重新形成的"特征"的任何想法在Access?
I've written SQL for many years, but I rarely use Access. In Access 2003, I wrote a SQL query with a subquery contained in parentheses. I ran it and it worked fine. When trying to run the query later, I got an error message. It appears that Access tried to format my query, and in doing so replaced the parentheses with brackets and inserted a semicolon at the end of the subquery. Needless to say, the query didn't run. Any idea on how to turn of this reformating "feature" in Access?
推荐答案
尝试为子查询提供别名:
Try to supply an alias to the subquery:
... FROM(SELECT * FROM table WHERE something)AS myAlias ...
... FROM (SELECT * FROM table WHERE something) AS myAlias ...
重新格式化为
... FROM [SELECT * FROM table WHERE something]。 AS myAlias ...
... FROM [SELECT * FROM table WHERE something]. AS myAlias ...
但应该继续工作。请注意,如果您使用[] 在子查询中(就好像你有一个生成错误的名称),这将无效,并且在这种情况下使用嵌套保存的查询是可行的方法。
but should continue to work. Note that if you use [ ] inside the subquery (as if you have an ill formed name), that won't work, and using a nested saved query is the way to go, in that case.
这篇关于如何阻止Access重新格式化并损坏我的子库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!