I have a simple table as below in MySQL. All I want to do is group records by PARENT ID and concatenate ATTRIBUTE records for that PARENT ID into the TYPE=’SIMPLE’ record.
UNIQUE ID | TYPE | Parent ID | Attribute |
---|---|---|---|
MYID1 | SIMPLE | MYID1 | |
MYID2 | VARIANT | MYID1 | WHITE |
MYID3 | VARIANT | MYID1 | BLUE |
So the result would be;
UNIQUE ID | TYPE | Parent ID | Attribute |
---|---|---|---|
MYID1 | SIMPLE | MYID1 | WHITE, BLUE |
MYID2 | VARIANT | MYID1 | WHITE |
MYID3 | VARIANT | MYID1 | BLUE |
How would I go about this?
Advertisement
Answer
Used GROUP_CONCAT very successfully