Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove duplicate data from mysql table accross two columns
    primarykey
    data
    text
    <p>I have a MySQL Table which looks like:<br> (unique_id, uid_data1, uid_data2, sorting_data1, sorting_data2)</p> <p>This table is used in a tool, where bidirectional relations weren't supported until now, so the table contains data that looks like (field order according line above):<br> (1, 1212, 2034, 1, 1)<br> (2, 2034, 1212, 1, 1)<br> (3, 4567, 9876, 1, 0)<br> (4, 9876, 4567, 0, 1)</p> <p>The table also contains "single-directed" relations, i.e.<br> (5, 5566, 8899, 1, 9)<br> => no row exists for (?, 8899, 5566, 9, 1)</p> <p>As the tool now supports bidirectional/symmetric relations, I would like to remove the duplicate data from the mysql table - however I'm having some trouble finding an appropriate query to do this.<br> In the example above I would like to delete the rows with the uids 2 and 4 (as their data is already stored in the rows 1 and 3.</p> <p>First, I tried to setup a SELECT-Statement to see, which entries would be deleted.<br> I thought of a JOIN-Query</p> <pre><code>SELECT x.uid, x.uid_link1, x.uid_link2, y.uid_link1 as 'uid_link2', y.uid_link2 as 'uid_link1' FROM tx_sdfilmbase_hilfstab x INNER JOIN tx_sdfilmbase_hilfstab y ON x.uid_link1=y.uid_link2 AND x.uid_link2=y.uid_link1 WHERE ??? ORDER BY x.uid_link1, x.uid_link2 </code></pre> <p>However I'm stuck at the point where I have to tell MySQL to only select "half portion" of the records.<br> Any suggestions on how to do this?</p> <p>P.S. Deleting each single record manually in the table isn't an option, as the table contains several thousand rows ;-)</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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