mysql - grouping but ignore if blank -


i'm trying group (or @ least make unique) column m_group_name unless group empty. see doesn't yet have group (and edited placed one) while being able see existing groups.

for example;

id  |  m_group_name ---------------------  1  | red  2  | blue  3  |   4  | red  5  |  

which, ideally, result in 1 red, 1 blue, , 2 blanks.

i've tried making blanks null , giving uuid value (after adapting similar found here on stackoverflow), seems make every null same value.

select *, ifnull(m_group_name,uuid()) m_group m group m_group 

ideally i'd rather not use null honest

edit: realised 'm_group_name' incorrectly labelled 'group' in example - corrected.

select * m length(group) in (0, null) *length(null) return null. length('') return 0.

am right want see rows don't yet have group?

edit: okay, read carefully. how this:

 select * m length(group) not in (0, null) group group  union  select * m length(group) in (0, null) 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -