Need help with a query
Hi. I have three tables, and if possible I'd like to get my data in one query rather than running multiple. My three tables are:
STORES:
index "sid"
varchar "store"
PRODUCTS:
index "id"
varchar "product"
INVENTORY:
index "iid"
int "id"
int "sid"
int "qty"
I have an item, I want to be able to get how many are in each store. The amount of stores is unknown, so I want to populate my datagrid dynamically. I'd like a query that would return something like:
[store,qty]
Downtown, 2
Mall, 12
I did SELECT store,qty FROM inventory i INNER JOIN stores s ON i.sid = s.sid WHERE i.id = (value). When an product has inventory in the stores, it works great. Problem is, when there is no inventory in a store it doesn't return a row for that store. Ideally if, say, downtown had none it should return:
[store,qty]
Downtown, (NULL)
Mall, 12
I tried changing to outer joins, but it still didn't return anything. How can I get this to work right?
Subject
Written By
Posted
Need help with a query
July 26, 2017 08:39PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.