使用Access 2010中的其他查询删除查询

时间:2016-06-15 14:10:37

标签: ms-access-2010 access

我在删除记录时遇到问题。我使用名为Asset_ID的字段链接了两个表,它是我的主键。我创建一个查询,拉出所有不匹配的记录,所以那些不匹配的记录我想删除它。当我运行查询它给我一个错误说“无法从指定的表中删除”,我做了一些研究,他们建议去我的删除查询属性并将选项“唯一记录”更改为是。没工作。请帮帮我。

我正在使用Access 2010查询构建器来执行此操作,但这是Sql代码:

DELETE DISTINCTROW [HANDHELD TABLE1 Without Matching HANDHELD TABLE].ASSET_ID
FROM [HANDHELD TABLE1 Without Matching HANDHELD TABLE]
WHERE ((([HANDHELD TABLE1 Without Matching HANDHELD TABLE].ASSET_ID) Is Not   Null));

这是我的HANDHELD TABLE1,没有匹配HANDHELD TABLE Sql。

SELECT [HANDHELD TABLE1].ASSET_ID, [HANDHELD TABLE1].INSPECTION_NUMBER, [HANDHELD TABLE1].INSPECTION_FLUSH, [HANDHELD TABLE1].LAST_PRESSURE, [HANDHELD TABLE1].LAST_INSPECT_DATE, [HANDHELD TABLE1].ADDRESS, [HANDHELD TABLE1].LOCATION_DESCRIPTION1, [HANDHELD TABLE1].COMMENTS, [HANDHELD TABLE1].MUNICIPALITY, [HANDHELD TABLE1].PRESSURE_ZONE, [HANDHELD TABLE1].FACILITY_CATEGORY, [HANDHELD TABLE1].LIFECYCLESTATUS, [HANDHELD TABLE1].MANUFACTURER, [HANDHELD TABLE1].INSP_BY, [HANDHELD TABLE1].PAINT, [HANDHELD TABLE1].[GROUND CLEARANCE], [HANDHELD TABLE1].[CURB CLEARANCE], [HANDHELD TABLE1].OBSTRUCTIONS, [HANDHELD TABLE1].[STUFFING BOX LEAK], [HANDHELD TABLE1].[CAULKING LEAK], [HANDHELD TABLE1].CAPS, [HANDHELD TABLE1].DRIP, [HANDHELD TABLE1].[DRIP COMMENTS], [HANDHELD TABLE1].FLUSHED, [HANDHELD TABLE1].[OIL STUFFING BOX], [HANDHELD TABLE1].[OIL CAPS], [HANDHELD TABLE1].DRAINAGE, [HANDHELD TABLE1].[DRAINAGE COMMENTS], [HANDHELD TABLE1].LUBRICATION, [HANDHELD TABLE1].[OPERATING NUT], [HANDHELD TABLE1].[OPERATING NUT COMMENTS], [HANDHELD TABLE1].NOZZLE, [HANDHELD TABLE1].[NOZZLE COMMENTS], [HANDHELD TABLE1].[MAIN WASHER], [HANDHELD TABLE1].[INSPECTION YEAR], [HANDHELD TABLE1].[TIME INSPECTED], [HANDHELD TABLE1].NOISE, [HANDHELD TABLE1].TIMEOPENED, [HANDHELD TABLE1].TIMECLOSED, [HANDHELD TABLE1].TIMETOCLEAR, [HANDHELD TABLE1].OPENEDCOLOR, [HANDHELD TABLE1].CLOSEDCOLOR, [HANDHELD TABLE1].FLUSHREMARKS, [HANDHELD TABLE1].DATEFLUSHED, [HANDHELD TABLE1].LASTFLUSHDATE, [HANDHELD TABLE1].FLUSHEDBY, [HANDHELD TABLE1].TIMEFLUSHED
FROM [HANDHELD TABLE1] LEFT JOIN [HANDHELD TABLE] ON [HANDHELD TABLE1].ASSET_ID = [HANDHELD TABLE].ASSET_ID
WHERE ((([HANDHELD TABLE].INSPECTION_FLUSH) Is Null) AND (([HANDHELD TABLE].ASSET_ID) Is Null));

1 个答案:

答案 0 :(得分:0)

从您提供的查询看起来,您将表连接到自身,以便查找检查刷新为空的字段。

然后您的问题将继续加入您的关键字段" ASSSET_ID"自己并寻找空值。这种情况永远不会成为关键领域。

尝试类似:

DELETE DISTINCTROW [HANDHELD TABLE_1].INSPECTION_FLUSH, [HANDHELD TABLE].*
FROM [HANDHELD TABLE] LEFT JOIN [HANDHELD TABLE] AS [HANDHELD TABLE_1] ON [HANDHELD TABLE].INSPECTION_FLUSH = [HANDHELD TABLE_1].INSPECTION_FLUSH
WHERE ((([HANDHELD TABLE_1].INSPECTION_FLUSH) Is Null));