Welcome Guest, Not a member yet? Register   Sign In
use foreach or single query? (Counting Inventory)
#1

[eluser]seanloving[/eluser]
I have a products table (product_id, part_number, description, price, etc)

I have an inventory table (inventory_id, product_id, serial_number, etc)

For each product in my products table I want to count the number of times the product_id appears on the inventory table.

Basically, I want to retrieve the entire products table, but with a 'quantity' field added to the results showing the count of each product in inventory.

I can show my code, but this is basically a procedural question. Right now I am using a foreach loop and it works just fine. However, I was wondering if there is a way to perform this operation as a SINGLE query?

Thanks!

SL


Messages In This Thread
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:21 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:35 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:49 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 09:05 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 09:29 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 10:24 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 11:07 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 12:20 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 01:54 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 02:02 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 03:43 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:05 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:43 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:46 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 08:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB