I am stuck with this sql problem :
DB : MySQL 5.6.15 storage engine : MyISAM
I have 3 tables :
1) products
id product | product_name
---------- | --------------
1 | alfa
2 | beta
3 | gamma
2) products_materials [this is the bridge table]
id product | id material
---------- | --------------
1 | 1
1 | 2
1 | 3
2 | 1
3 | 1
3) materials
id material| material_name
---------- | --------------
1 | steel
2 | gold
3 | silver
I need to obtain this result :
id product | material_name_1 | material_name_2 | material_name_3
------------|--------------------|-------------------|--------------------
product 1 steel gold silver
product 2 gold null null
product 3 silver null null
The max materials per product is 10. I had a look to pivot but i am not confident enough with it to create the right query.
Thanks a lot