Before I start does anyone have any useful pointers in writing some code to generate a list of all possible product combinations based on a matrix of options
PRODUCT A PRODUCT B OPTION 1 Blue x x
Red x
OPTION 2 Long
x
Short x x
A - Blue - Short A - Long - Short
B - Blue - Long B - Blue - Short
Obviously the actual matrix has a lot more options etc.
TIA
Chris.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Chris,
Research CROSS JOINs...
Bill Anderson
On Wed, Sep 18, 2024 at 6:03 AM Chris Davis chrisd@actongate.co.uk wrote:
Before I start does anyone have any useful pointers in writing some code to generate a list of all possible product combinations based on a matrix of options
PRODUCT A PRODUCT B OPTION 1 Blue x x
Red x
OPTION 2 Long
x
Short x x
A - Blue - Short A - Long - Short
B - Blue - Long B - Blue - Short
Obviously the actual matrix has a lot more options etc.
TIA
Chris.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Hi Chris,
like pointed out by Bill, use Cross Join.
In VFP SQL, a cross join is a join without any criteria.
Put the Product code in a table or cursor, do the same for Option 1 and Option 2 and Option ...
Then do the following query:
select ; Product.Code, ; Option_1.Option as Option_1, ; Option_2.Option as Option_2 ; from Product, Option_1, Option_2 ; order by 1, 2, 3 ; into cursor Combinations
HTH, Gianni
On Wed, 18 Sep 2024 12:54:50 +0000, Chris Davis chrisd@actongate.co.uk wrote:
Before I start does anyone have any useful pointers in writing some code to generate a list of all possible product combinations based on a matrix of options
PRODUCT A PRODUCT B OPTION 1 Blue x x
Red x
OPTION 2 Long
x
Short x x
A - Blue - Short A - Long - Short
B - Blue - Long B - Blue - Short
Obviously the actual matrix has a lot more options etc.
TIA
Chris.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
Thank you both I will give this a try later today.
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Gianni Turri Sent: 19 September 2024 12:58 To: profoxtech@leafe.com Subject: Re: Matrix
Hi Chris,
like pointed out by Bill, use Cross Join.
In VFP SQL, a cross join is a join without any criteria.
Put the Product code in a table or cursor, do the same for Option 1 and Option 2 and Option ...
Then do the following query:
select ; Product.Code, ; Option_1.Option as Option_1, ; Option_2.Option as Option_2 ; from Product, Option_1, Option_2 ; order by 1, 2, 3 ; into cursor Combinations
HTH, Gianni
On Wed, 18 Sep 2024 12:54:50 +0000, Chris Davis chrisd@actongate.co.uk wrote:
Before I start does anyone have any useful pointers in writing some code to generate a list of all possible product combinations based on a matrix of options
PRODUCT A PRODUCT B OPTION 1 Blue x x
Red x
OPTION 2 Long
x
Short x x
A - Blue - Short A - Long - Short
B - Blue - Long B - Blue - Short
Obviously the actual matrix has a lot more options etc.
TIA
Chris.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]