Mysql Duplicate rows - same table - not primary col


/ Published in: MySQL
Save to your folder(s)

Look for duplicate rows, in the same table, by a different column (not primary or unique).


Copy this code and paste it in your HTML
  1. SELECT p1.id,p1.cod , p2.id,p2.cod #here we find the duplicate data from cod column, but i need the ID to show ...
  2. FROM `st_produse` p1 #the table, first time
  3. LEFT JOIN st_produse p2 ON p1.cod = p2.cod #the table second time
  4. WHERE p1.id <> p2.id #here put the key or a unique column
  5. GROUP BY p1.cod #the column in case, first time

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.