Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
No Duplicates
Message
From
03/05/2010 20:46:57
 
 
To
30/04/2010 18:08:53
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01462570
Message ID:
01462928
Views:
43
>>Hello All!1
>>i have this table that has dupllicates and i want to delete all the duplicatates an be only left with one oof the duplicated record. During that time i realized i dint know an SQL that could say that so decided to do an sql using the no duplicated. but then that only works for indexed records an will not work for everything in a TAble. So is there another way i can express what i want to the DAtabase?
>
>All the following is based on the assumption you are working with VFP tables. If that's not true, feel free to ignore....
>
>Are the records complete duplicates in that ALL fields in the record are the same? If so, then something like
>SELECT DISTINCT * FROM myTable INTO CURSOR myCursor NOFILTER
>DELETE FROM myTable
>INSERT INTO myTable SELECT * FROM myCursor
>
>The old records will still be hanging around marked for deletion and you will need to PACK the table to make them disappear.
>
>If it's only a subset of fields that mark the records as duplicates then you might try something like
>SELECT *, 000000 as idrec FROM myTable INTO CURSOR crsTemp READWRITE
>REPLACE ALL idrec WITH RECNO()
>SELECT <dup field list>,MIN(idRec) AS idRec FROM crsTemp GROUP BY <dup field list> INTO CURSOR crsDUPS
>SELECT crsTemp.* FROM crsTemp JOIN crsDups ON crsTemp.idrec = crsDups.idrec INTO CURSOR crsAppend NOFILTER
>SELECT myTable
>DELETE ALL
>APPEND FROM DBF('crsAppend')
>
>It's not the most "modern" of code, but I think it should work for you. (or at least get you started)

will
select distinct work?cause that only works for indexs an u said select distinct * from my table ann...not all are indexes but ill play around with your second code thou should get me started an yes im using vfp tables
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform