for example I have few tables:
Products:
| product_id | name | price |
| 1 | apple | 20.32 |
| 2 | pear | 9.99 |
| 3 | banana | 1.5 |
Product attribute:
| attr_id | name | value |
| 1 | weight | 10 kg |
| 2 | date | 2013 |
| 3 | color | red |
...and so on.
Finally product-attribute relations table:
| product_id | attr_id |
| 1 | 3 |
| 2 | 1 |
| 1 | 2 |
| 3 | 2 |
My question : is there available construct ONE select request query that returns product 1 and 2 in following data structure(or similar)? Now I should run deveral select requests first "where product_id IN (1, 2)" and then throught loop select them attributes.
Sorry for bad English :]
array(
[0] = array(
product_id = 1,
name = apple,
attributes= array(
[0] => array(
attr_id = 3,
name = color,
value = red,
),
[0] => array(
attr_id = 2,
name = date,
value = 2013,
)
),
),
[1] = array(
product_id = 2,
name = apple,
attributes= array(
[0] => array(
attr_id = 1,
name = veight,
value = 10 kg,
),
),
)
)