mysql if() with max()
问题 I have a table named attproduct : there are three columns id, attribute, values . I have color and brand for each id in attribute column and corresponding values in value column SELECT id, MAX( IF( attribute = 'brand', value, NULL ) ) AS Brand, MAX( IF( attribute = 'color', value, NULL ) ) AS color FROM fy.attproduct GROUP BY id When I run this query i get output as desired in id, brand, color as columns. I need to know what is role of max in my query, when i remove max, i get null values 回答1