我有三张桌子
--Categories--
id, Name
-- Products --
id, name, price
-- productCategories --
id, product_id, category_id
我想得到类似的产品。
例如。我写的名字得到类似的产品
SELECT * FROM products
where products.name in (select products.name from products
join productcategories on products.id=productcategories.product_id
group by products.name having count(*)>1)
但我不能通过类别来获得相似的产品。 我写了这样的东西,但这是错的
SELECT * FROM products
where
products.name in(select products.name from products join productcategories
on products.id=productcategories.product_id
join Categories on productcategories.category_id =Categories.id)
你可以帮助我吗?