Hi all,
I have a query, and I know I should be able to solve it using an outer join, but I cant get it to work, can someone help!
The three tables I'm pulling data back from are item, category and stock. The item table holds details about the item, and it is linked to category by Category_ID. The category table just holds what type of item it is, and a general description about that categry. The stock table just holds the Item_ID and a Quantity value.
I want to bring back all these details about this item, even when there is none in stock (quantity is null).
I wrote this query so far:
SELECT *
FROM item, category
WHERE category.Category_ID = item.Category_ID
And it brings back the item with the correct category name etc. Then I went on to get the stock quantity, knowing that some items were not in stock:
SELECT *
FROM item, category LEFT OUTER JOIN stock ON item.Item_ID = stock.Item_ID
WHERE category.Category_ID = item.Category_ID
This brings back a whole list of values, which are incorrect, please can someone help me sort this query out!
Thank you
I have a query, and I know I should be able to solve it using an outer join, but I cant get it to work, can someone help!
The three tables I'm pulling data back from are item, category and stock. The item table holds details about the item, and it is linked to category by Category_ID. The category table just holds what type of item it is, and a general description about that categry. The stock table just holds the Item_ID and a Quantity value.
I want to bring back all these details about this item, even when there is none in stock (quantity is null).
I wrote this query so far:
SELECT *
FROM item, category
WHERE category.Category_ID = item.Category_ID
And it brings back the item with the correct category name etc. Then I went on to get the stock quantity, knowing that some items were not in stock:
SELECT *
FROM item, category LEFT OUTER JOIN stock ON item.Item_ID = stock.Item_ID
WHERE category.Category_ID = item.Category_ID
This brings back a whole list of values, which are incorrect, please can someone help me sort this query out!
Thank you