'Filter table rows with multiple conditions from related table
I have a table named Product related with another table named ProductAttribute.
ProductAttribute:
ID,
ProductId,
Value,
AttributeID
And I need to get all products with these conditions:
AttributeID=1017 AND Value='false'
AttributeID=1011 AND Value='200'
I tried this query
SELECT T0.*
FROM Product T0
INNER JOIN ProductAttribute T1
ON T1.ProductID = T0.ID
WHERE (T1.AttributeID = 1011 AND T1.Value = 'false')
AND
(T1.AttributeID = 1017 AND T1.Value = '200')
But the result was empty. And tried this query
SELECT T0.*
FROM Product T0
INNER JOIN ProductAttribute T1
ON T1.ProductID = T0.ID
WHERE (T1.AttributeID = 1011 AND T1.Value = 'false')
OR
(T1.AttributeID = 1017 AND T1.Value = '200')
But the result was every row has one of the two conditions.
I need the rows that fulfill the two conditions together.
this is the ProductAttribute table's data:

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
