I have to make it to show how many categories are available that are not currently any products in. Not sure what I am doing wrong, since I have moved stuff around and still get the result of 682 rows when there is supposed to be 0.
SELECT
Quantity,
ProductName,
CategoryID
FROM
Products,
OrderItems
WHERE NOT EXISTS (
SELECT Quantity
FROM OrderItems
WHERE Quantity IS NULL
)
Was told that "NOT EXIST" needs to be used in it.
You need a join condition between the tables. First hint: Never use commas in the
FROM
clause. Always use proper, explicitJOIN
syntax.I assume you want something like this:
The exact syntax is a bit of a guess, because you don't provide sample data.