Hi
I am trying to delete some duplicate rows, i have searched some of the previous posts on this and have developed this, but it does not quite work.
Basically, i have CandSkillID is the PK for this table, i need to delete records that have duplicate SkillID, and where the CandID = 89431.
Currently it does not delete any rows, i believe the problem lies within the embedded SELECT statement, because that does not return rows when executed on its own.
Thanks Si
Delete *
From tblCandAndSkill AS T
WHERE T.CandSkillID IN
(SELECT CandSkillID, SkillID
FROM tblCandAndSkill
WHERE CandID = 89431
GROUP BY CandSkillID, SkillID Having Count(*) > 1)
AND CandSkillID <
(Select MAX(X.[CandSkillID])
FROM tblCandANDSkill As X
Where X.SkillID = T.SkillID
Group By X.SkillID)
I am trying to delete some duplicate rows, i have searched some of the previous posts on this and have developed this, but it does not quite work.
Basically, i have CandSkillID is the PK for this table, i need to delete records that have duplicate SkillID, and where the CandID = 89431.
Currently it does not delete any rows, i believe the problem lies within the embedded SELECT statement, because that does not return rows when executed on its own.
Thanks Si
Delete *
From tblCandAndSkill AS T
WHERE T.CandSkillID IN
(SELECT CandSkillID, SkillID
FROM tblCandAndSkill
WHERE CandID = 89431
GROUP BY CandSkillID, SkillID Having Count(*) > 1)
AND CandSkillID <
(Select MAX(X.[CandSkillID])
FROM tblCandANDSkill As X
Where X.SkillID = T.SkillID
Group By X.SkillID)