Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL select and combining cursors/tables
Message
 
 
To
03/10/2001 14:20:48
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00563768
Message ID:
00564431
Views:
15
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform