what is the query to delete the duplicate records from Table
Moderator: General Moderators
-
dkshri_jain
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 27, 2005 12:03 am
- Location: India
- Contact:
what is the query to delete the duplicate records from Table
what is the query to delete the duplicate records from Table ?
define duplicate... once you know which attributes (column values) that are used to determine if they are the same you could do it like:
Code: Select all
DELETE FROM table
WHERE tableid IN (
SELECT tableid
FROM table
GROUP BY (attribute1, attribute2, ...)
HAVING COUNT(*) > 1
)Code: Select all
select count(*) as count, `record` from `table`group by `record`edit timvw's is better