Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2008, 11:51 PM
Authorized User
 
Join Date: Jan 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Duplicate Records in a table

   Some times we have duplicate records in a table and we need to check that which records are duplicated.

   A few days ago i had the similar kind of problem and even after a long web search i was unable to find any solution.

   I have designed this query to find "duplicate records in a table" and it works very well. i have tested it on sql server and access databases and haven't yet on oracle and other DBMS. I like to share it so that if any one have same kind of problem, he can find it here easily next time.

this is the sql query

         "select id from MyTable
          group by id
          having count(id) > 1"



 
Old January 28th, 2008, 07:11 PM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello there,

What query do you use to pull the original data?
 
Old February 7th, 2008, 07:40 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This only checks if the id field is duplicated. If the ID field matches but some or all of the other fields are different (thus not a dupe) this query will count it as a dupe.






Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicate records vanitha SQL Server 2000 4 June 2nd, 2007 04:35 PM
duplicate records vanitha Reporting Services 2 May 31st, 2007 01:54 AM
Delete Duplicate Records prasanta2expert SQL Server 2000 9 December 15th, 2006 10:44 PM
Duplicate Records mrookey Dreamweaver (all versions) 1 April 15th, 2005 11:23 AM
No Duplicate Records Error crapanz PHP Databases 0 September 28th, 2004 07:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.