访问查询以根据复杂条件删除数据
Access Query to Delete data based on Complex criteria
我正在使用 Access 2013。我有一个 Table 名称 - Raw
及其字段是:
requestid - Number
Formname - Short Text
Timestamp - Date/Time
Type - Short Text
ActionBy - Short Text
Raw
table 包含所有数据。相同的请求 ID 将具有不同的 Types
和 actionby
。我想删除那些请求 ID 的所有行,其中特定请求 ID 的任何 actionby
与我的用户不匹配。如果匹配,则保留所有行。
示例 - 在屏幕截图中,请求 ID 27176 让 Ciaran 处于行动状态。因此,它不应删除请求 ID 27176 的任何行。
但是,对于请求 ID 27434,ciaran 不在 Actionby 中,因此请删除 27176 的所有行。希望我能够瞥见我需要的内容。
您可以使用 NOT IN
和一些字符串操作来识别要删除的那个:
delete from raw as r
where requestid not in (select requestid
from raw as r2
where r2.ActionBy = "Harford, Claran" and
r2.requestid = r.requestid
);
我正在使用 Access 2013。我有一个 Table 名称 - Raw
及其字段是:
requestid - Number
Formname - Short Text
Timestamp - Date/Time
Type - Short Text
ActionBy - Short Text
Raw
table 包含所有数据。相同的请求 ID 将具有不同的 Types
和 actionby
。我想删除那些请求 ID 的所有行,其中特定请求 ID 的任何 actionby
与我的用户不匹配。如果匹配,则保留所有行。
示例 - 在屏幕截图中,请求 ID 27176 让 Ciaran 处于行动状态。因此,它不应删除请求 ID 27176 的任何行。
但是,对于请求 ID 27434,ciaran 不在 Actionby 中,因此请删除 27176 的所有行。希望我能够瞥见我需要的内容。
您可以使用 NOT IN
和一些字符串操作来识别要删除的那个:
delete from raw as r
where requestid not in (select requestid
from raw as r2
where r2.ActionBy = "Harford, Claran" and
r2.requestid = r.requestid
);