I think you should go with the first idea, doing this via idea 2 would require some hand editing of code.
You would need to craft the query with a join, you can do some math directly in the sql like this:
SELECT (table1.inventory - table2.ordered) AS available_inventory
FROM table1 JOIN table2 ON table1.id = table2.foreignkey
WHERE available_inventory > 0
Obviously this is just an example of how you could do this in a query, your query will look different. Please post back with any additional questions that you have about this or any other part.