Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with SQL select and combining cursors/tables
Message
 
 
À
03/10/2001 14:20:48
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00563768
Message ID:
00564431
Vues:
16
Hi Peter,
If I understand you correctly, you want to add all SD records to BM table w/o creating duplicates. I also assume that you have a primary key field ID in BD table. If don't than it can be created with one more select
SELECT *, RECNO() AS Id ;
  FROM bmdata INTO CURSOR cursBM
See my corrections and additions below
>** read EXACT matches
>select * from bmdata left join sddmdata ;
>  on left(&bmzip,5)=left(sddmdata.sdzip,5) ;
>  where !empty(trim(sddmdata.sdaddr)) and ;
>        upper(trim(&bmlname))=upper(trim(sddmdata.sdlname)) and ;
>        upper(trim(&bmaddr))=upper(trim(sddmdata.addr)) ;
  into cursor cursExact
>
>** read PROBABLE matches
>select * from bmdata left join sddmdata ;
>  on left(&bmzip,5)=left(sddmdata.sdzip,5) ;
>  where !empty(trim(sddmdata.sdaddr)) and ;
>        upper(trim(&bmaddr))=upper(trim(sddmdata.addr)) ;
     <b>And Id Not In (Select Id From cursExact)</b> ;
  into cursor cursProb
>
>** read POSSIBLE matches
>select * from bmdata left join sddmdata ;
>  on left(&bmzip,5)=left(sddmdata.sdzip,5) ;
>  where !empty(trim(sddmdata.sdaddr)) and ;
>        val(trim(&bmaddr))=val(trim(sddmdata.addr)) 
     <b>And Id Not In (Select Id From cursExact)</b> ;
     <b>And Id Not In (Select Id From cursProb)</b> ;
   into cursor cursPoss

<b>SELECT * ;
  FROM bmdata ;
  WHERE ;
     Id Not In (Select Id From cursExact) ;
       And Id Not In (Select Id From cursProb) ;
       And Id Not In (Select Id From cursPoss) ;
   into cursor cursNewBD</b>
Now you can add all records from SD to the records in the cursor cursNewB.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform