我有 2 张桌子:
1 Category
- cID
- Name
- Active
2 Products
- pID
- Name
- category_id
- active
这就是我想要的:我想要一个来自只有 ACTIVE 产品的类别的列表。
提前致谢
解决方案:SELECT DISTINCT category.* FROM category INNER JOIN products ON category.id = products.c_id WHERE products.active = 0 ORDER BY category.id DESC