The 2 code statements below are from the same query as its represented in both a SELECT and a DELETE query type.
QUESTION / PROBLEM: Can the DELETE code below be modified to effect the same result as the SELECT code? More specifically: If, for example, my table contains one set of duplicates, the SELECT code will present/select only 1 of the duplicate pair. While the DELETE code will present/delete the complete pair???
Thank you in advance,
SELECT DISTINCT TableName.Field1, TableName.Field2
FROM TableName
WHERE (((TableName. Filed1) In (SELECT [Field1] FROM [TableName] As Tmp GROUP BY [Field1],[Field2] HAVING Count ([TableName].[Field1])>1 And [Field2] = [TableName].[Field2])));
______________________________________________
DELETE DISTINCTROW TableName.Field1, TableName.Field2
FROM TableName
WHERE (((TableName. Field1) In (SELECT [Field1] FROM [TableName] As Tmp GROUP BY [Field1],[Field2] HAVING Count ([TableName].[Field1])>1 And [Field2] = [TableName].[ Field2])));
QUESTION / PROBLEM: Can the DELETE code below be modified to effect the same result as the SELECT code? More specifically: If, for example, my table contains one set of duplicates, the SELECT code will present/select only 1 of the duplicate pair. While the DELETE code will present/delete the complete pair???
Thank you in advance,
SELECT DISTINCT TableName.Field1, TableName.Field2
FROM TableName
WHERE (((TableName. Filed1) In (SELECT [Field1] FROM [TableName] As Tmp GROUP BY [Field1],[Field2] HAVING Count ([TableName].[Field1])>1 And [Field2] = [TableName].[Field2])));
______________________________________________
DELETE DISTINCTROW TableName.Field1, TableName.Field2
FROM TableName
WHERE (((TableName. Field1) In (SELECT [Field1] FROM [TableName] As Tmp GROUP BY [Field1],[Field2] HAVING Count ([TableName].[Field1])>1 And [Field2] = [TableName].[ Field2])));