Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Join command
Message
 
 
À
30/03/2004 22:28:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00891068
Message ID:
00891072
Vues:
30
>my problem is how to join this 2 tables in this format ;
create cursor tbl1 ( scode c(2) )

insert into tbl1 values ( "c1" )
insert into tbl1 values ( "c2" )
insert into tbl1 values ( "c3" )
insert into tbl1 values ( "c4" )

create cursor tbl2 ( scode c(2), itemcode c(4), qty i )
insert into tbl2 values ( "c1", "itm4", 1 )
insert into tbl2 values ( "c2", "itm2", 2 )
insert into tbl2 values ( "c3", "itm3", 1 )
insert into tbl2 values ( "c4", "itm1", 4 )

select distinct itemcode ;
   from tbl2 ;
   into cursor allItems nofilter

select tbl1.scode, allitems.itemcode, tbl2.qty ;
   from tbl1 ;
   full outer join allItems ;
      on .t. ;
   left join tbl2 ;
      on tbl1.scode = tbl2.scode and allitems.itemcode = tbl2.itemcode ;
   into cursor x1 ;
   having ! isnull( tbl1.scode )
this will give you a result with .null. values in the qty column for rows that don't match up. you can use nvl() to convert these to 0 values instead. But it may be useful to you to know the difference between a tbl2 row with 0 qty from missing rows.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform