Hello I have a table in some cms (products) that has 3 columns:
product_id feature_id value
1 1 blue
1 8 cotton
2 5 t-shirt
2 1 red
3 8 wool
1 9 large
Each product has its own id, also each product has a list of features
(about 10 of them) each feature_id represent’s a feature. Depending on
the feature_id the “value” column has the value for that type of feature.
E.x. imagine clothes, 1 unique product_id -> 1 cloth -> many features / properites like color type of material price size etc etc.
Question is it possible to fetch 3 rows something like
product_id value1 value2
1 blue large
2 red medium
3 green xsmall
4 purple xlarge
where value1 is the string on the value column when products 1 feature_id = 1 and
value2 is the string on the value column when products 1 feature_id = 9 (feature_id for size)
I cant figure out how to do this in one statement, without having to merge arrays in php.
Well after some testing this works great 🙂