How to List Duplicate Records in a Field

ID: Q115617

2.00 2.50 2.50a 2.50b 2.60 | 2.50 2.50a 2.50b 2.60 | 2.50b 2.50c

MS-DOS                     | WINDOWS                    | MACINTOSH
kbprg

The information in this article applies to:

This article describes how to generate a list of duplicate records in a database.

The following code uses a query to generate the list of duplicates and then stores it in a cursor named LISTING:

   USE c:\foxprow\tutorial\invoices
   SELECT invoices.cno, COUNT(invoices.cno) FROM invoices ;
    GROUP BY invoices.cno ;
    HAVING COUNT(invoices.cno)>1 ;
    INTO CURSOR listing

There will be two fields in the cursor LISTING, the first being customer numbers that have duplicates, and the second being the number of duplicates for that customer number.

Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 2.50c identical same repeated table KBCategory: kbprg KBSubcategory: FxprgGeneral

Keywords          : FxprgGeneral 
Version           : 2.00 2.50 2.50a 2.50b 2.60 | 2.5
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 1, 1996