Two tables
1) product
--------------------
id | Name | price
1 | p1 | 10
2 | p2 | 20
3 | p3 | 30
2) product_attributes:
---------------------------------------------------
id | product_id | attribute_name | attribute_value
---------------------------------------------------
1 | 1 | size | 10
2 | 1 | colour | red
3 | 2 | size | 20
I need to join these two tables. In the where clause I need to match both the
two rows attribute values. Is it possible to get the result based on two rows
value. Based on the user selection,I need to display all the products matching the condition. Here if size=10 and colour=red.
Output should be
1 | p1 | 10
It could be greatly helpful to get a query for this.
If you need to match more attributes, just add more joins to the subquery.