尝试自动删除Access 2013数据库中的重复行 [英] Trying to automate removal of a duplicate row in Access 2013 database

查看:75
本文介绍了尝试自动删除Access 2013数据库中的重复行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动化Access 2013中的进程,我可以删除数据库中的重复行。我需要做的是为每个重复的员工行删除一行。我认为我需要做的是:
$
SELECT TOP 1 [ID]

来自数据库AS DB

WHERE(EmpID按类似分组值;这里需要语法)



EmpID    特殊#    营业时间和NBSP;   名称和NBSP;      ID

1001               2         FT        蝙蝠侠     499

1001               2         FT        蝙蝠侠     495

1025               2         FT        罗宾       233

1025               2         FT        罗宾       228



我想要的是每个员工的两个ID之一,所以我可以使用ID删除该行。我不关心我删除哪两行。我永远不应该有超过两行相同的情况。

I am trying to automate a process in Access 2013 where I can delete a duplicate row in a database. What i need to do is delete one row for each of the duplicated employee lines. What I think I need to do is:
SELECT TOP 1 [ID]
FROM database AS DB
WHERE (EmpID is grouped by like values; need syntax here)

EmpID    Special#    Hours    Name       ID
1001               2        FT        Batman    499
1001               2        FT        Batman    495
1025               2        FT        Robin       233
1025               2        FT        Robin       228

What I want is one of the two IDs for each of the employees so I can use the ID to delete the row. I do not care which of the two rows I delete. I should never have a situation where there is more than two rows that are the same.

谢谢,

Christopher

Christopher

推荐答案

嗨克里斯托弗,

Hi Christopher,

一种可能的方式可能是:

One possible way could be something like:

DELETE FROM TABLENAME

DELETE FROM TABLENAME

WHERE ID IN(SELECT MAX(ID)

WHERE ID IN(SELECT MAX(ID)

FROM TABLENAME

FROM TABLENAME

GROUP BY EMPID

GROUP BY EMPID

有COUNT(*)> 1)

HAVING COUNT(*)>1)

(未经测试)

希望它有所帮助。 ..

Hope it helps...


这篇关于尝试自动删除Access 2013数据库中的重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆