MAX()
is combining the values associated with each id.
SELECT id, IF( attribute = 'brand', value, NULL ) AS Brand, IF( attribute = 'color', value, NULL ) AS color
FROM fy.attproduct
without the GROUP BY
should return rows like
ID Brand color
1 'mybrand' NULL
1 NULL 'mycolor'
When MAX()
is not used, only one of the rows will be chosen, so at least one column will be NULL
.