Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GET RID OF DUPLICATES
Message
From
28/11/2000 12:34:26
 
 
To
28/11/2000 12:19:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00446244
Message ID:
00446266
Views:
8
One way I can think of:
SET DELETED ON

SCAN
   lcCity = Upper(AllTrim(MyTable.City))
   lcState = Upper(AllTrim(MyTable.State))
   lcCountry = Upper(AllTrim(MyTable.Country))
   lcTerritory = Upper(AllTrim(MyTable.Territory))
   SELECT Count(MyTable.*) AS Cnt;
      FROM MyTable;
      WHERE (Upper(AllTrim(MyTable.City)) == lcCity) AND;
            (Upper(AllTrim(MyTable.State)) == lcState) AND;
            (Upper(AllTrim(MyTable.Country)) == lcCountry) AND;
            (Upper(AllTrim(MyTable.Territory)) == lcTerritory)
      INTO CURSOR curTemp

   IF curTemp.Cnt > 1
      SELECT MyTable
      DELETE
   ENDIF

   USE IN curTemp
ENDSCAN
HTH
>I have a table with the following fields:
>
>city
>state
>county
>territory
>
>There are several thousand records. I want to get rid of all of the duplicates; Just have one record for each unique record.
>
>Does anyone have an example of code that would go through the table and mark all but one of all duplicate records for deletion?
Previous
Reply
Map
View

Click here to load this message in the networking platform