我有两个表[月比尔决赛]和[新研究成员决赛]共享许多相同的领域和数据。我需要删除[Month Bill Final]中的值为"重复SSN"在[New Research Members Final]表中的[Research Flag]字段中。我已经在下面的SQL中的字段上加入了表,但是我一直收到错误"无法从指定的表中删除"。
DELETE [Month Bill Final].*, [New Research Members Final].[Research Flag]
FROM [Month Bill Final] INNER JOIN [New Research Members Final] ON ([Month Bill Final].[First Name] = [New Research Members Final].[First Name]) AND ([Month Bill Final].[Last Name] = [New Research Members Final].[Last Name]) AND ([Month Bill Final].[Date of Birth] = [New Research Members Final].[Date of Birth]) AND ([Month Bill Final].[Subscriber SSN] = [New Research Members Final].[Subscriber SSN]) AND ([Month Bill Final].[Employee SSN] = [New Research Members Final].[Employee SSN])
WHERE ((([New Research Members Final].[Research Flag])="Duplicate SSN"));
答案 0 :(得分:0)
您只能在DELETE语句中定位一个表。从SQL中删除, [New Research Members Final].[Research Flag]
。
答案 1 :(得分:0)
在操作查询中使用联接可能会产生不明确的结果。避免他们。 DELETE和FROM之间也应该没有任何内容。 试试这个:
DELETE
FROM [Month Bill Final]
WHERE EXISTS
(
SELECT '1'
FROM [New Research Members Final]
WHERE [Month Bill Final].[First Name] = [New Research Members Final].[First Name]
AND [Month Bill Final].[Last Name] = [New Research Members Final].[Last Name]
AND [Month Bill Final].[Date of Birth] = [New Research Members Final].[Date of Birth]
AND [Month Bill Final].[Subscriber SSN] = [New Research Members Final].[Subscriber SSN]
AND [Month Bill Final].[Employee SSN] = [New Research Members Final].[Employee SSN]
AND [New Research Members Final].[Research Flag]="Duplicate SSN"
);