Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select statement not getting what I want
Message
De
01/02/2007 15:51:08
 
 
À
01/02/2007 15:42:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01191605
Message ID:
01191612
Vues:
9
This message has been marked as a message which has helped to the initial question of the thread.
>Hi All
>
>
>Table RTable
>r_id       r_cover
>AAQ02        21
>AAQ02        10
>BA02Q        31
>
>Table STable
>S_id       f_cover    fromdate     todate      s_no
>AAQ02        21      08/01/2006  03/30/2007     1
>AAQ02        10      08/01/2006  03/30/2007     2
>BA02Q         9      08/01/2006  10/31/2006     3
>
>
>
>I want to get a cursor that contains all info from both tables
>
>r_id    s_id    r_cover f_cover    fromdate     todate      s_no
>AAQ02  AAQ02    21        21      08/01/2006  03/30/2007     1
>AAQ02  AAQ02    10        10      08/01/2006  03/30/2007     2
>.NULL. BA02Q   .NULL.      9      08/01/2006  10/31/2006     3
>BA02Q  BA02Q    31        31        .NULL.      .NULL.     .NULL.
>
>
>I have tried:
>
>SELECT rtbl.r_id, rtbl.r_cover, stbl.s_id, stbl.fromdate, ;
>  stbl.todate, stbl.s_no, stbl.f_cover FROM RTable rtbl ;
>  FULL OUTER JOIN STable stbl ;
>    ON PADR(rtbl.r_id,12) + STR(rtbl.r_cover, 2) = ;
>      PADR(stbl.s_id, 12) + STR(stbl.f_cover, 2) ;
>  WHERE inlist(r_id, "AAQ02  ", "BA02Q  ") ;
>  INTO CURSOR cCovers
>
>
>I have tried Left Join, Left Outer Join, and Outer Join to no correct results.
>Can anyone, please, point out what I am doing wrong.
>
>TIA
>Beth

Remove INLIST, or if you want it for certain records only then specify tables:
SELECT A.r_id, A.r_cover, B.s_id, B.fromdate, ;
B.todate, B.s_no, B.f_cover FROM RTable A ;
FULL OUTER JOIN STable B ;
ON PADR(A.r_id,12) + STR(A.r_cover, 2) = ;
PADR(B.s_id, 12) + STR(B.f_cover, 2) ;
WHERE inlist(A.r_id, "AAQ02  ", "BA02Q  ") ;
And inlist(B.r_id, "AAQ02  ", "BA02Q  ") ;
INTO CURSOR cCovers
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform