0
Select DISTINCT product_class.product_category
From line_items
    JOIN product
        on line_items.product_id = product.product_id
    JOIN product_class
        on product_class.product_class_id = product.product_class_id

Select DISTINCT product_category
from product_class
4

1 回答 1

1

不太清楚你到底在追求什么。我猜你想拥有 line_items 中不存在的 product_class 中的所有类别/类别。

如果是这样,这是一个解决方案

SELECT DISTINCT product_category FROM product_class WHERE product_class_id NOT IN (
SELECT DISTINCT product_class_id FROM product WHERE product_id in (
SELECT DISTINCT product_id FROM line_items))
于 2013-04-22T03:43:33.127 回答