I want to remove duplicate records from a table without using temp table how is it possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Example.
Assuming a table named
table, with an autoincrement ID column namedidand a column namednameof which you want to remove the doubles. Of each name, you want to keep the oldest record (the one with the lowest ID).Query A then looks something like:
Query B would be:
Now combine these to form the delete query:
In the example at hand, you could leave out the first query, but when things get more complicated, it’s a nice extra safeguard.