我有以下选择查询,我需要转换为删除查询以删除重复项。
麻烦的是我似乎无法让删除部分工作。在“查询”构建器中,这将选择我需要删除的记录。
SELECT [Field1], [Field2], [Field3], [Field4], COUNT([Field4]) AS CountOfDuplicates
FROM MyTable
GROUP BY [Field1], [Field2], [Field3],[Field4]
HAVING (COUNT([Field4])>1)
将SELECT更改为DELETE会导致错误'Missing FROM Clause'
由于
答案 0 :(得分:0)
不是我原本想做的,但我选择了这个选项。创建另一个表以通过SELECT * INTO表FROM表GROUP BY *
删除重复项这将删除重复的行。
SELECT [Field1], [Field2], [Field3], [Field4]
INTO tempTable
FROM MyTable
GROUP BY [Field1], [Field2], [Field3],[Field4];
DELETE * FROM MyTable;
INSERT INTO MyTable SELECT tempTable.* FROM tempTable;