Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Delete duplicate row in table

    • 0
    • 2
    • 3
    • 1
    • 0
    • 0
    • 0
    • 0
    • 327
    Comment on it

    You can delete the duplicate row without using the temporary table. You can use the self join concept.

    Suppose we have person table contain 3 columns named id, name, and city. INSERT INTO person(id,name,city) VALUES (1,'a', 'aa'), (2,'b','bb'), (3,'d','dd'), (4,'d','dd'), (3,'a','aa');

    Now we have to delete the duplicate row from table. You can see the duplicate record from following query:

    select * from person  p1, person p2 where  p1.id >  p2.id;
    

    Now you can delete duplicate recored using the following query.

    delete from person  p1, person p2 where  p1.id >  p2.id;
    

    Hope this will help you.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: