How to remove duplicates from table using SQL query

后端 未结 7 1573
遇见更好的自我
遇见更好的自我 2020-12-17 04:34

I have a table which is as follows:

emp_name   emp_address  sex  matial_status  
uuuu       eee          m    s
iiii       iii          f    s
uuuu       eee         


        
相关标签:
7条回答
  • 2020-12-17 05:39

    I know this is old post, but recently I tested a solution and want to share if any one can find my solution helpful -

    CREATE TABLE tmpTable LIKE yourTable; insert into tmpTable (col1, col2 ... colN) SELECT distinct col1, col2 ... colN FROM yourTable WHERE 1; drop table yourTable; RENAME TABLE tmpTable TO yourTable;

    Please note, insert into statement may execute without primary key.

    Thanks.

    0 讨论(0)
提交回复
热议问题