从多个表中删除 [英] delete from multiple tables

查看:96
本文介绍了从多个表中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我打算同时从2个表中删除记录。

Dear all,
I plan to delete records from 2 tables at a same time.

展开 | 选择 | 换行 | 行号

推荐答案

访问删除查询一次不能从多个表中删除。这是访问限制,与distinctrow的使用无关。


您将需要使用两个删除查询,每个表一个。


-Stewart
Access delete queries cannot delete from more than one table at a time. This is an Access limitation and nothing to do with the use of distinctrow.

You will need to use two delete queries instead, one for each table.

-Stewart


如果两个表都已连接且参照完整性设置为删除是级联的,那么您可以通过简单地删除两个表来同时从两个表中删除记录记录在链接的一侧。


EG。可以设置[tblSchool]和[tblPupil]来反映学生与学校之间的关系。如果链接是按照描述设置的,并且某个学校从[tblSchool]中删除,则[tblPupil]中的所有相关记录也将被删除。
If both tables are connected and referential integrity set such that deletes are cascaded then you can cause records to be deleted from both tables at the same time by simply deleting the record on the One side of the link.

EG. [tblSchool] and [tblPupil] could be set up to reflect the relationship between a pupil and their school. If the link is set up as described and a particular school is deleted from [tblSchool] then all related records from [tblPupil] will also be removed.


这绝对是可能的,我知道根据最近的经验,因为我试图阻止相反的情况发生:我有一个数据表子表单绑定到一个查询,涉及两个表之间的连接,并从数据表中删除记录默认情况下将删除连接的两侧,我想只删除一方。


我同意斯图尔特你的情况与DISTINCTROW无关。


过去我在没有明确指定表名的情况下使用了DELETE,所以我想知道如果从DELETE子句中删除 a。* 会发生什么?


Pat
It is definitely possible, which I know from recent experience because I was trying to prevent the opposite from happening: I had a datasheet subform bound to a query that involved a join between two tables, and upon deletion of a record from the datasheet both sides of the join would get deleted by default, whereas I wanted only one side deleted.

I agree with Stewart that your situation has nothing to do with DISTINCTROW.

In the past I have used DELETE without explicitly specifying a table name, so I do wonder what would happen if you removed a.* from the DELETE clause?

Pat


这篇关于从多个表中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆