Checking for Duplicate Records in your Database
This query will check if you have a duplicate record in your database.
SELECT * from
TableName a WHERE ((SELECT COUNT(*) FROM TableName b WHERE b.id = a.id) > 1)
Sometimes it is important to know if you have a duplicate record in a specific table. You can do this by having a sub query joined by the id's and count all the records in the sub query. If the sub query is greater then 1, you have a duplicate in that table.

0 comments:
Post a Comment