Remove duplicate rows on many to many table (Mysql)

Incognito

I have a table which is many to many and my table looks like this

+----+--------+
|  Customers  |
+----+--------+
| id | name   |
+----+--------+
| 1  | john   |
| 1  | john   |
| 1  | james  |
| 2  | george |
| 2  | michael|
+----+--------+

What i want is to remove the duplicate rows with the same name.

Gordon Linoff

Unfortunately, you have no way to distinguish one row from another. So, the easiest way to do this is the temporary table approach:

create table temp as
    select distinct id, name
    from customers;

truncate table customers;

insert into customers(id, name)
    select id, name
    from temp;

drop table temp;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Remove duplicate rows on many to many table (Mysql)

From Dev

many to many query mysql return duplicate rows

From Dev

How to remove duplicate rows in Excel 2013 when there are many columns?

From Dev

Many to Many join with the least duplicate rows

From Dev

Large db table with many rows or many columns

From Dev

Deleting many rows from a big table MySql 5.5.46

From Dev

Remove duplicate rows from MySQL table (ignore chars and whitespace)

From Dev

Mysql - Is there a way to query a many-to-many relationship and include rows not in the linking table?

From Dev

Entity Framework 6 Many-to-many wants to insert duplicate rows

From Dev

Entity Framework 6 Many-to-many wants to insert duplicate rows

From Dev

saveOrUpdate many-to-many table with Hibernate + MySQL

From Dev

MySQL: Counting instances in many-to-many table

From Dev

Insert into Many to Many Table - Node JS MySQL

From Dev

Prevent duplicate entries in a join table in a many-to-many relationship in JPA

From Dev

Prevent duplicate entries in a join table in a many-to-many relationship in JPA

From Dev

Printing duplicate rows as many times it is duplicate in the input file using UNIX

From Dev

Mysql - search in "one to many" table

From Dev

Mysql - search in "one to many" table

From Dev

Mysql redesign table with many columns

From Dev

MySQL delete duplicate rows in table

From Dev

Finding duplicate rows in a MySQL table

From Dev

Find missing rows from table through a many to many relation

From Dev

Postgres : get min and max rows count in many to many relation table

From Dev

Structure a table with many uneven rows and columns - HTML

From Dev

Structure a table with many uneven rows and columns - HTML

From Dev

SQL - Remove Duplicate Rows From Table

From Dev

LINQ - how to remove duplicate rows in table

From Dev

Duplicate and Remove Table Rows through Jquery

From Dev

MYSQL - Select rows fulfilling many count conditions

Related Related

  1. 1

    Remove duplicate rows on many to many table (Mysql)

  2. 2

    many to many query mysql return duplicate rows

  3. 3

    How to remove duplicate rows in Excel 2013 when there are many columns?

  4. 4

    Many to Many join with the least duplicate rows

  5. 5

    Large db table with many rows or many columns

  6. 6

    Deleting many rows from a big table MySql 5.5.46

  7. 7

    Remove duplicate rows from MySQL table (ignore chars and whitespace)

  8. 8

    Mysql - Is there a way to query a many-to-many relationship and include rows not in the linking table?

  9. 9

    Entity Framework 6 Many-to-many wants to insert duplicate rows

  10. 10

    Entity Framework 6 Many-to-many wants to insert duplicate rows

  11. 11

    saveOrUpdate many-to-many table with Hibernate + MySQL

  12. 12

    MySQL: Counting instances in many-to-many table

  13. 13

    Insert into Many to Many Table - Node JS MySQL

  14. 14

    Prevent duplicate entries in a join table in a many-to-many relationship in JPA

  15. 15

    Prevent duplicate entries in a join table in a many-to-many relationship in JPA

  16. 16

    Printing duplicate rows as many times it is duplicate in the input file using UNIX

  17. 17

    Mysql - search in "one to many" table

  18. 18

    Mysql - search in "one to many" table

  19. 19

    Mysql redesign table with many columns

  20. 20

    MySQL delete duplicate rows in table

  21. 21

    Finding duplicate rows in a MySQL table

  22. 22

    Find missing rows from table through a many to many relation

  23. 23

    Postgres : get min and max rows count in many to many relation table

  24. 24

    Structure a table with many uneven rows and columns - HTML

  25. 25

    Structure a table with many uneven rows and columns - HTML

  26. 26

    SQL - Remove Duplicate Rows From Table

  27. 27

    LINQ - how to remove duplicate rows in table

  28. 28

    Duplicate and Remove Table Rows through Jquery

  29. 29

    MYSQL - Select rows fulfilling many count conditions

HotTag

Archive