Hi there,
I've tried to figure this out myself, but the views documentation didn't get me much further (or rather, made me think what I'm trying to do is beyond the scope of views?), so if anyone could help me out here, that'd be fantastic.
I'm currently porting my website into Drupal, and have an assembly-kit management in it. Functionality-wise, the following happens: Users can define a list of items they own, and at the same time there is a database of project, listing instructions and the required items to build them. Now, what I want it a display of which projects a user can attempt based on his inventory, and for which he needs to buy additional items first.
The query for this uses a negative check, counting the items a user needs in addition to what he has. $uInventory is a string with all the item IDs from his inventory, and $difference is the amount of additional items required that should be shown.
$query=<<<ENDE
SELECT project, COUNT(DISTINCT item) AS Num
FROM rel_pro_item
WHERE item NOT IN ($uInventory)
GROUP BY project
HAVING Num = $difference
ENDE;
There is a dummy item in every project and in no inventory to make this query work, so $difference has to be at least one, then showing all projects that a user can attempt with his current inventory.