Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT - SQL
Message
De
14/06/1999 21:11:05
 
 
À
14/06/1999 11:25:22
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00229458
Message ID:
00229805
Vues:
20
Here's an idea on how to find out the duplicate keys in a table

SELECT keyfield, count(*) as keycount FROM MyTable INTO CURSOR Duplicates GROUP BY keyfield
SELECT *, recno() as recnumber FROM MyTable INNER JOIN Duplicates ON (MyTable.keyfield == Duplicates.keyfield) WHERE Duplicates.keycount > 1 INTO CURSOR DuplicateKeys

Be careful with recno() when used with more than one table. You better select first everything + a new column based on recno() from each table into cursors and work with those cursors (the recno() columns will act as unique keys).

Can you use something like this?

Vlad

>Well, for the past week, I have been asking for help and didn't get much out of this. Let me say this, I am NOT asking you to write the codes for me. I need help on HOW to do such and sometimes writing a "head start" coding helps me best. This is for VFP 6.0 (SP3 ;)
>
>What I need here is somehow to do a query and the biggest, hardest part is there ARE duplicates key fields to work with. So far, I have come up with using SET DELETED ON, but I don't think it is a good idea. I will for once again explain what I need to do. The WORKPO is what is imported from XLS file and the HISTPO is history for one fiscal year. The KEY field (index or whatever, but can have duplicates) the is "PO" field. This project will be run on a daily basics (supposed to be due this week!!!)
>
>WORKPO.dbf vs HISTPO.dbf
>
>If there is ONE OR MORE PO in WORKPO and NONE in HISTPO, this record(s) is new and will be added to HISTPO. This step would be the most to happen.
>
>If there are (list are different samples but same concept):
>TWO PO in WORKPO and THREE PO in HISTPO
>FOUR PO in WORKPO and TWO PO in HISTPO
>TWO PO in WORKPO and ONE PO in HISTPO
>[A#] PO in WORKPO and [B#] PO in HISTPO ([A#] <> [B#])
>the matching PO record(s) that are in HISTPO must be removed/deleted and the updated PO from WORKPO need to be added/replaced into the HISTPO. Need to keep the HISTPO update with the latest data.
>
>If there is ONE PO record in WORKPO and ONE PO record in HISTPO, all I would need to do is compare the fields. If there is ANY changes to ANY field(s), the HISTPO must be UPDATED with what is in the WORKPO.
>
>If there are (list are different samples but same concept):
>THREE PO in WORKPO and THREE PO in HISTPO
>FIVE PO in WORKPO and FIVE PO in HISTPO
>[A#] PO in WORKPO and [A#] PO in HISTPO ([A#] = [A#])
>I need to compare the PO in the WORKPO with the PO in the HISTPO. The thing is (common senses) once the PO matches the other PO (meaning ALL the fields matches), I need to "mark" those two record and not "re-use" the same record to match the other POs. If there is none match PO in either table, it would be like (2nd sample) that the [A#] PO need to be removed/deleted from the HISTPO and the [A#] PO from WORKPO need to be added/replaced into the HISTPO.
>
>Can you see the whole picture? What I need help with is HOW to program this. Should I use SELECT - SQL [INTO CURSOR]?? VIEW?? I need help with how to do a route, checking WITH DUPLICATES PO in BOTH tables... This is little odd, but I can understand this. If you kind can help me and need to ask me anything, email me or reply this post. I will check this thread OFTEN today... THANK YOU!!!
>
>Chuck
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform