Search code examples
sqldatabasegoogle-chromecommandsql-delete

deleting duplicates in the mysql database


I recently created a database for myself and I have a problem looking for duplicates. My point is that a given number in the database does not appear 2 times and I would like to detect something like that with a command. for now I have something like this but unfortunately it does not work. I would like several tables to be searched because the numbers will be entered into each of them. i created database in mysql

DELETE a FROM `SomeoneA` AND 'SomeoneB' AS a INNER JOIN `SomeoneA` AND 'SomeoneB' AS b WHERE a.number < b.number AND a.id = b.id

Solution

  • Your delete join syntax is slightly off:

    DELETE a
    FROM SomeoneA AS a
    INNER JOIN SomeoneB AS b
        ON a.id = b.id
    WHERE a.number < b.number;