I have a table having below data,trying to delete duplicate rows from table. For example:ab=ba,cd=dc..
Please suggest.
ab
ac
ad
ba
bc
bd
da
db
dc
ea
eb
ec
ed
fa
fb
fc
fd
This query joins the table with itself. The WHERE condition ensures t2 only holds the values to delete (ie. it will delete ca but not ac).
DELETE t2.*
FROM `table` t1
INNER JOIN `table` t2 ON t1.letters<t2.letters AND REVERSE(t1.letters)=t2.letters;
If you want to see what values would be deleted, just replace DELETE with SELECT in the query.
testand table columnnamlikeselect * from test where nam > reverse(nam) and nam in (select reverse(nam) from test). But I do not know how to delete them, since it is not allowed to reference the table you want to delete in a where-clause. Maybe you can save them and delete with the next step.