 <p>you can also use this query for test:</p> <pre><code>UPDATE dupli d SET description = ( SELECT CONCAT('duplicate in ',GROUP_CONCAT(`id` ORDER BY id)) FROM (SELECT * FROM dupli) AS d1 WHERE `name` = d.`name` AND id &lt;&gt; d.id ) ; </code></pre> <p><strong>sample</strong></p> <pre><code>MariaDB [yourSchema]&gt; UPDATE dupli d -&gt; SET description = ( -&gt; SELECT CONCAT('duplicate in ',GROUP_CONCAT(`id` ORDER BY id)) -&gt; FROM (SELECT * FROM dupli) AS d1 -&gt; WHERE `name` = d.`name` AND id &lt;&gt; d.id ) ; Query OK, 0 rows affected, 1 warning (0.00 sec) Rows matched: 4 Changed: 0 Warnings: 1 MariaDB [yourSchema]&gt; select * from dupli; +----+------+------------------+ | id | name | description | +----+------+------------------+ | 1 | foo | duplicate in 3,4 | | 2 | bar | NULL | | 3 | foo | duplicate in 1,4 | | 4 | foo | duplicate in 1,3 | +----+------+------------------+ 4 rows in set (0.00 sec) MariaDB [yourSchema]&gt; </code></pre>