I have two different tables, products and inventory.
Basically, what I’m trying to accomplish is I need to loop thru every row in my products table and reference the corresponding rows in the inventory table.
My goal is to find out what products have a quantity of 0.
The inventory table has multiple rows for each product id. The problem I’m facing is that ALL inventory rows that correspond to a particular product need to have a quantity of 0 for the result to be of any use to me (this is what I’m trying to figure out)
Right now, I’m just looping thru every product and then executing a second SQL statement that checks for any occurrences of quantity > 0 in the inventory table for the selected product, but that doesn’t work with my pagination script (20k rows in the product table, many more in the inventory table. displaying all at once is not an option)
You should just preform an inner-join between the two tables and then select where
quantity == 0.Something like: