是否可以获取具有常见id_feature_values的所有id_products?
id_feature | id_product | id_feature_value
---------- | ---------- | -----------------
17 | 4900 | 388
18 | 4900 | 398
20 | 4901 | 400
21 | 4901 | 401
17 | 4902 | 388
17 | 4902 | 398
例如,我想要id_products的id_feature_value 388和398,所以我需要的结果是4900和4902.
谢谢!
答案 0 :(得分:1)
您可以这样做:
SELECT DISTINCT id_product FROM <tablename> WHERE id_feature_value IN (398, 388) GROUP BY id_product HAVING COUNT(id_feature_value)=2