如何在 MS-Access 中创建相关更新子查询?
我正在规范化几个表,并且已向名为 Exams
的表添加了一个代理主键,该表包含考试标题。
以前,子表仅使用考试的完整名称作为 FK 条目。
现在我已经向表中添加了一个自动编号字段,我想更新使用它的条目,例如问题所在的表,因为有超过一千个问题。
每次找到名称后,通过修改后的更新来完成每次考试都需要一段时间,因此我决定在 UPDATE
查询中编写相关子查询。查询如下所示:
UPDATE tblExamQuestion
SET ExamID = (SELECT ExamID FROM tblExam WHERE ExamName = tblExamQuestion.ExamName);
不幸的是,一旦我编写了子查询部分,Access 就拒绝给我运行
选项,而只显示设计视图、数据表视图< /em> 和该查询的 SQL 视图。但是,它仍然在对象资源管理器中显示“更新查询”图标。
是否有正确的方法来编写此内容,以便 Access 不会感到不安?
使用:Access 2007 和 Access 2003 MDB 数据库。
I'm in the process of normalizing a few tables and I've added a surrogate primary key to a table called Exams
which holds exam titles.
Previously, the child tables would just use the entire name of the exam as the FK entry.
Now that I've added a autonumbered field to the table, I want to update the entries that use it such as the table where the questions are from as there are over a thousand of them.
Going through each exam with a modified update once I find the name each time would take a while, so I decided to write a correlated subquery in a UPDATE
query. The query looks like this:
UPDATE tblExamQuestion
SET ExamID = (SELECT ExamID FROM tblExam WHERE ExamName = tblExamQuestion.ExamName);
Unfortunately, once I write the subquery portion, Access refuses to give me the Run
option and just displays the Design View, Datasheet View and SQL View for that query. However, it still displays the Update Query icon in the object explorer.
Is there a proper way to write this so that Access doesn't get upset?
Using: Access 2007 with a Access 2003 MDB database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不:
Why not: