I’m trying to group (or at least make unique) a column m_group_name unless the group is empty. This is to basically see what doesn’t yet have a group (and could then be edited to be placed into one) while being able to see the existing groups.
For example;
id | m_group_name
---------------------
1 | Red
2 | Blue
3 |
4 | Red
5 |
Which, ideally, would result in one red, one blue, and 2 blanks.
I’ve tried making the blanks NULL and giving it a UUID value (after adapting something similar found here on Stackoverflow), but it seems to make every NULL the same value.
SELECT *, IFNULL(m_group_name,UUID()) AS m_group FROM m GROUP BY m_group
Ideally I’d rather not use NULL to be perfectly honest
EDIT:
Realised that ‘m_group_name’ was incorrectly labelled as ‘group’ in the example – corrected.
SELECT * FROM m WHERE LENGTH(Group) IN (0, NULL)*
LENGTH(NULL)will returnNULL.LENGTH('')will return0.am I right that you want to see ALL the rows that DON’T yet have a
Group?EDIT:
Okay, i read it carefully. How about this: