Hi There,
I can't seem to see what's wrong with the query below
DELETE
FROM Users_Details UD1
WHERE UD1.UserID = (
SELECT TOP 1 UD2.UserID
FROM Users_Details UD2
WHERE UD1.useremail = UD2.useremail
)
Keeps giving me incorrect syntax on Line 1 near UD1.
Can you not alias tables when using a Delete?
What I'm trying to do is cleanse the table of duplicate e-mail
addresses but I always want to leave one copy of the e-mail address
i.e. if there are 3 of the same e-mail address then I want to remove 2
of them.
Anyone got a better way of doing it that doesn't use cursors then I
would appreciate it.
Cheers
I can't seem to see what's wrong with the query below
DELETE
FROM Users_Details UD1
WHERE UD1.UserID = (
SELECT TOP 1 UD2.UserID
FROM Users_Details UD2
WHERE UD1.useremail = UD2.useremail
)
Keeps giving me incorrect syntax on Line 1 near UD1.
Can you not alias tables when using a Delete?
What I'm trying to do is cleanse the table of duplicate e-mail
addresses but I always want to leave one copy of the e-mail address
i.e. if there are 3 of the same e-mail address then I want to remove 2
of them.
Anyone got a better way of doing it that doesn't use cursors then I
would appreciate it.
Cheers
Comment