Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
All Combinations of Group Members (challenging)
Message
From
08/09/2005 17:37:51
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01047849
Message ID:
01047891
Views:
11
Hey Chad,

Never mind, I think I've got it. Thanks a bunch!

Aloha,

James

>James,
>
>If you are wanting ALL the possible permutations, you could do something like this:
>
>USE IN SELECT('curTest')
>SELECT 0
>CREATE CURSOR curTest ( ;
>		iPK int AUTOINC NEXTVALUE 1 STEP 1, ;
>		cName char(10), ;
>		cAddress char(10), ;
>		cCompany char(10))
>
>INSERT INTO curTest ;
>		(cName, cAddress, cCompany) ;
>	VALUES ;
>		('Chad', 'Texas', 'TUES')
>
>INSERT INTO curTest ;
>		(cName, cAddress, cCompany) ;
>	VALUES ;
>		('James', 'Hawaii', 'DataCraft')
>
>INSERT INTO curTest ;
>		(cName, cAddress, cCompany) ;
>	VALUES ;
>		('Bob', 'Oregon', 'Microsoft')
>
>
>SELECT c1.cName, c2.cAddress, c3.cCompany ;
>	FROM curTest c1 ;
>		INNER JOIN curTest c2 ;
>			ON .t. ;
>		INNER JOIN curTest c3 ;
>			ON .t. ;
>	ORDER BY c1.cName, c2.cAddress, c3.cCompany
>
>For narrowed down results, you can change the ON clauses to something like this:
>
>INNER JOIN curTest c2 ;
>	ON c1.iPK # c2.iPK ;
>INNER JOIN curTest c3 ;
>	ON c1.iPK # c3.iPK ;
>		AND c2.iPK # c3.iPK ;
>
>You can also see if changing INNER to FULL makes any difference.
>
>HTH,
>Chad
>
>
>>Hi All,
>>
>>I'm hoping someone can help me out here.
>>
>>I want to find out how I can generically obtain all the different combinations of group members. The trick is the number of groups is not set and neither is the number of group members.
>>
>>Example:
>>
>>A table has a group of name fields, could be one name, could be three or four names. The same table has a group of addresses, again could be one or two or three.
>>
>>I want to create a cursor that contains one record for each combination of name and address.
>>
>>Record 1: name1+address1
>>Record 2: name2+address1
>>Record 3: name3+address1
>>Record 4: name1+address2
>>Record 5: name2+address2
>>Record 6: name3+address2
>>
>>If it were only name and address that would be alright, however the trick is to get it to work so that another group could be added, say company names and there are more one or more company names as well.
>>
>>In that case the cursor should look something like the following:
>>
>>Record 1: name1+company1+address1
>>Record 2: name2+company1+address1
>>Record 3: name3+company1+address1
>>Record 4: name1+company2+address1
>>Record 5: name2+company2+address1
>>Record 6: name3+company2+address1
>>Record 7: name1+company1+address2
>>Record 8: name2+company1+address2
>>Record 9: name3+company1+address2
>>Record10: name1+company2+address2
>>Record11: name2+company2+address2
>>Record12: name3+company2+address2
>>
>>Aloha,
>>
>>James
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform