Jump to content

A querying question


JamesHunt

Recommended Posts

Its a little more than a querying question, its a problem I have come to in the planning for something I want to write. I start with 2 comma separated databases, well \t separated databases at least and that gets pasted into a textarea. I have no problem processing that into two arrays, the raw comma separated databases look something like these (but much much longer):

 

productForSale, quantityForSale, costToBuy, seller
Cake, 12, 100, James
Apple, 100, 30, Scott
Beer Keg, 20, 250, Scott
Cheese, 50, 60, Benjamin
Bow, 10, 300, James

 

productWanted, quantityWanted, offer, buyer
Bow, 1, 400, Bob
Cheese, 50, 100, James
Cake, 20, 90, Sarah
Cake, 10, 110, Bob
Apple, 60, 35, James
Long Sword, 1, 500, Benjamin

 

So I end up with an array of things for sale and an array of things that are wanted. I'm sure you already know what I want to do, I want to match up the things for sale with the things wanted so that the most profitable trades are outputted. With a database and SQL I could do this easily but without putting it into a database I don't know what to do.

 

The reason I don't want to use tables is that I don't want the the data to be persistent, the things both for sale and wanted change quickly. It will be ran every time trading is to be done.

 

Is there any way to perform SQL on an array as it were.

 

Any help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/122155-a-querying-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.