Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple SQL?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 8
Divers
Thread ID:
01287483
Message ID:
01287510
Vues:
9
>>>What would be the syntax to get the ctrl#,item from 2 like tables where customer='JONES'? My syntax returns duplicates from table 2.
>>>
>>>SELECT a.ctrl,a.item,b.ctrl,b.item FROM e:csu8 a , e:csu7 b ;
>>>WHERE a.cust_name = b.cust_name AND a.cust_name='JONES'
>>
>>Do you have multiple items for this customer in Table2? If yes, what criteria do you want to use to get only one item?
>
>Here are the tables.
>table 1
>
>  JONES           TAPE DISPENSER                 7VS0055
>  JONES           LABELS                         7VS0056
>  JONES           POWER CORD                     7VS0057
>
>table 2
>
>
>  JONES           TONER CARTRIDGE GPR16          8RV0155
>  JONES           FILTER CAP HYDROSTAT RESERVOI  8RV0216
>  JONES           INKJET PRINT CARTRIDGE HP #57  8RV0257
In your case you may want to create one extra key (record number) to use it as a join condition, e.g.
select 100 as RecID, Ctrl, Item from Table1  where cust_Name = 'JONES' into cursor curA readwrite
select 100 as RecID, Ctrl, Item from Table2  where cust_Name = 'JONES' into cursor curB readwrite

replace all RecID with recno() in curA
replace all RecID with recno() in curB

select * from curA inner join curB on curA.RecID = curB.RecID
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform