I have a query which returns:
uid | text | flag | nonuid | another_id
123 | "tree" | 1 | 176 | 7098
456 | "apple" | 1 | 321 | 9686
321 | "apple" | 0 | | 5675
847 | "tree" | 1 | 176 | 6456
993 | "car" | 1 | 332 | 9686
222 | "cat" | 0 | | 7098
913 | "car" | 0 | | 2301
176 | "tree" | 0 | | 6456
982 | "car" | 1 | 332 | 7098
332 | "car" | 0 | | 7321
uid: unique field for every record
text: not unique piece of text
flag: whenever this is a "repost" entry of another row
nonuid: uid of the original of the repost
another_id: process_id that created the entry
I need to "collapse this list, so that nonuid appears only once in the list. If the field is empty, then there is no repost, so the entire row should be displayed. So after running the "right" query I should see the same list like this:
uid | text | flag | nonuid | another_id: GROUP_CONCAT(another_id)
123 | "tree" | 1 | 176 | 7098,6456
456 | "apple" | 1 | 321 | 9686
321 | "apple" | 0 | | 5675
993 | "car" | 1 | 332 | 9686,7098
222 | "cat" | 0 | | 7098
993 | "car" | 0 | | 9686
176 | "tree" | 0 | | 6456
332 | "car" | 0 | | 7321
I could GROUP BY the list by text, but uid 332 and uid 222 have same text, while both not being a repost - and I should keep the original and the repost. Alternatively I could collapse by nonuid, which also fails, since all the "empty" nonuid become grouped together.
textandnonuid?nonuidfield occurence and another_id is a group concat - it is fine.