Delete all duplicate records using mysql or sql

Suppose you have a table like below example and now you want to delete all duplicate records from this table -

Suppose we have a table tbl_user which containing two fields :

Table name : tbl_user

x------x--------------------x
    id           name
x------x--------------------x
    1            salman
    2            salman
    3            rohit
    4            sumit    
    5            sanjay
    6            rohit
x----------------------------x


Now i want to delete all repeated record from my table tbl_user like salman, rohit and i want only single records .

Sql Query :

CREATE TABLE tbl_new_user as SELECT * FROM tbl_user WHERE 1 GROUP BY name;


If you like this post please don't forgot to post a comment to notify me.

Happy coding guys :) 

Post a Comment

Previous Post Next Post