我有三张 table .
Table : products
column : id, productname
Table :attribute_master
column : id, attributename
Table : assignedproductfilter
column : id, productid (FK products), filterid (FK attribute_master)
table assignedproductfilter
可能包含多个 productid
,多个 filterid
.
示例:
| id | productid | filterid |
|----|-----------|----------|
| 1 | 105 | 56 |
| 2 | 105 | 50 |
| 3 | 105 | 34 |
| 4 | 200 | 56 |
| 5 | 201 | 22 |
现在,假设我想获得 filterid
为56,50和34的所有产品 . 所有这三个 filter id
都应分配给 products
.
如何在mysql中为此编写查询?
1 回答
请下次再询问尝试自己尝试之前 .
并使用像sqlfiddle这样的东西或只包含你的模式定义SQL .