Hie Lars Berg!
Thanks alot for ur suggestion..I didnt know u can query it that way!
But i am still stuck trying to modify abit. Apparently, I wont be able to know my wine_id because user are called to input the wine_name which from there I could know the wine_id. But the problem is, user may also not input anything which means to generate all wines. My pc was hang when generating that query as the database is very large. Any ideas? Here is the code so far:
"SELECT wine_name, variety, year, winery_name, region_name, MIN(cost), on_hand, sum(on_hand),
(select count(*) from items where wine_id = inventory.wine_id)
FROM wine, wine_variety, winery, region, grape_variety,inventory
WHERE wine_name LIKE '{$wineName}%' AND
winery_name LIKE '{$wineryName}%' AND
wine.wine_id = wine_variety.wine_id AND
winery.winery_id = wine.winery_id AND
wine_variety.variety_id = grape_variety.variety_id AND
region.region_id = winery.region_id AND
inventory.wine_id = wine.wine_id
GROUP BY wine.wine_id, variety ORDER BY wine_name,year,variety";