Note that there are some explanatory texts on larger screens.

plurals
  1. POFind duplicate rows violating unique constraint on several fields
    primarykey
    data
    text
    <p>My CMS upgrade has the following query:</p> <pre><code>ALTER IGNORE TABLE locales_target ADD PRIMARY KEY (language, lid, plural) </code></pre> <p>It failed because of: "Duplicate entry '1-0' for key 'PRIMARY'".</p> <p>I actually added the IGNORE myself on the query above, but it didn't help because table use the InnoDB engine, so the errors were not actually ignored.</p> <p>This page shows how to find duplicate rows that would violate a unique contraint: <a href="http://www.tocker.ca/2013/11/06/the-future-of-alter-table-ignore-syntax.html" rel="nofollow">http://www.tocker.ca/2013/11/06/the-future-of-alter-table-ignore-syntax.html</a> </p> <pre><code>SELECT GROUP_CONCAT(id), emailaddress, count(*) as count FROM users GROUP BY emailaddress HAVING count &gt;= 2; </code></pre> <p>but it does so for a unique field. How do I find duplicate rows with the 3-field primary key?</p> <p>Edit: the original question still stands but here is some more information and more related questions:</p> <p>1) what does '1-0' stand for in the error message? There are no rows where lid == 0!</p> <p>2) The following query highlighted part of the problem:</p> <pre><code>mysql&gt; select lid, count(*) as count from france_locales_target group by lid having count != 1; +------+-------+ | lid | count | +------+-------+ | 1 | 2 | | 2 | 2 | | 3 | 2 | | 4 | 2 | | 5 | 2 | | 6 | 2 | | 7 | 2 | | 8 | 2 | etc. etc. </code></pre> <p>Now, given that I use InnodDB and that IGNORE does not work, how would I go about gracefully deleting the duplicate rows?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload