Hello,

I have a database structured like this:
user
item ID
have this many items
want this many items

for example:
bob 23 1 2
joe 14 0 1

bob has 1 of item 23 and wants 2 more
Joe has 0 of item 14 and wants 1 of it

Now what I'd like to do is figure out which pair of people should trade
(they can have more than 1 item in the database). i.e., person A has
most of the items on person B's wants list, while person B has most of
the items on person A's wants list.

I'm thinking of finding the difference between person A's haves and
person B's wants, then saving that as a 'score', and repeating this
process for all the other people's wants compared to person A's haves
(and keeping a variable that remembers the highest score).

Is there a better way? Like through SQL?

thanks,
dragonhunter