DELETE FROM TableName WHERE ColumnId NOT IN ( SELECT MAX(ColumnId) FROM TableName GROUP BY LTRIM(RTRIM(ColumnDuplicate)))
Here, TableName - Table name from which you want to remove duplicate rows. ColumnId - Primary Key column which has unique value. ColumnDuplicate - It is Column name which contains duplicate values.
Example: Following example will delete all rows with duplicate title in Forum table.
DELETE FROM Forum WHERE ForumId NOT IN ( SELECT MAX(ForumId) FROM Forum GROUP BY LTRIM(RTRIM(ForumTitle)))
|