Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating cursor with 3 fields from source table
Message
De
08/04/2007 23:45:53
Randy Wessels
Screentek Business Solutions, Llc.
Phoenix, Arizona, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01213336
Message ID:
01213346
Vues:
10
That worked great - thank you.

>You have to use UNION to comboine 3 reps into one cursor
>
>
>SELECT invpost.salesrep1 as salesrep,
>		PADR(ALLTRIM(salesrep.fname) + ' ' + ALLTRIM(salesrep.lname),50) as repname
>	FROM invpost
>		JOIN salesrep on invpost.salesrep1 = salesrep.salesrep
>	 WHERE NOT EMPTY(invpost.salesrep1)
>UNION
>SELECT invpost.salesrep2 as salesrep,
>		PADR(ALLTRIM(salesrep.fname) + ' ' + ALLTRIM(salesrep.lname),50) as repname
>	FROM invpost
>		JOIN salesrep on invpost.salesrep2 = salesrep.salesrep
>	 WHERE NOT EMPTY(invpost.salesrep2)
>UNION
>SELECT invpost.salesrep3 as salesrep,
>		PADR(ALLTRIM(salesrep.fname) + ' ' + ALLTRIM(salesrep.lname),50) as repname
>	FROM invpost
>		JOIN salesrep on invpost.salesrep3 = salesrep.salesrep
>	 WHERE NOT EMPTY(invpost.salesrep3)
>ORDER BY 1
>INTO CURSOR curRep
>
>
>>Still learning SQL so after a few google searches giving no good results, I figured I would bug the experts. I am trying to get a list of all the unique salesreps (and their names) used in an order into a cursor. The problem is the reps are in three seperate fields on the table: salesrep1, salesrep2, and salesrep3. I am not sure if I need to use three seperate queries and do some sort of combining or if I can do it all in a 1 select statement. The statement below works great for one of the reps. Any help would be appreciated.
>>
>>SELECT distinct invpost.salesrep1 as salesrep,ALLTRIM(salesrep.fname) + ' ' + ALLTRIM(salesrep.lname) as repname FROM invpost,salesrep ;
>> INTO CURSOR curRep WHERE invpost.salesrep1 = salesrep.salesrep AND !EMPTY(invpost.salesrep1) ORDER BY invpost.salesrep1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform