Ok, this is causing me a headache as I just can't figure out how to go about this without getting stuck in a massive loop!
Here's a little scenrio..
Customer A
Needs Bread
Has Milk to sell
Customer B
Needs Milk
Has Bread to sell
So simply
and CustomerB would be returned...
Now what if I wanted to expand on this so that...
Customer A
Needs Bread
Has Milk to sell
Customer B
Needs Beans
Has Bread to sell
Customer C
Needs Milk
Has Beans to sell
So CustomerA needs CustomerB but CustomerB doesn't need what CustomerA has to sell but CustomerB does need what CustomerC has and CustomerC needs what CustomerA has to sell.
I could wait for a perfect match but ideally if I can get the three of them together then everyone gets what they want.
I just cannot think how on earth to do this! There's bound to be some sort of mathematical solution to this but I was never that good at math!
Any takers? Think of it as a puzzle!
Thanks
Here's a little scenrio..
Customer A
Needs Bread
Has Milk to sell
Customer B
Needs Milk
Has Bread to sell
So simply
Code:
select CustID from customers where need='Milk' and wants='Bread'
and CustomerB would be returned...
Now what if I wanted to expand on this so that...
Customer A
Needs Bread
Has Milk to sell
Customer B
Needs Beans
Has Bread to sell
Customer C
Needs Milk
Has Beans to sell
So CustomerA needs CustomerB but CustomerB doesn't need what CustomerA has to sell but CustomerB does need what CustomerC has and CustomerC needs what CustomerA has to sell.
I could wait for a perfect match but ideally if I can get the three of them together then everyone gets what they want.
I just cannot think how on earth to do this! There's bound to be some sort of mathematical solution to this but I was never that good at math!
Any takers? Think of it as a puzzle!
Thanks