如何使用组concat和分隔符显示空值
select sr.aID,
GROUP_CONCAT(p.GENDER SEPARATOR ',') as Gender,
GROUP_CONCAT(sr.FANS SEPARATOR ',') as FA,
from RELATION sr, Person p where RELATION _TYPE = 'FATHER'
and sr.bID= p.ID group by sr.subjektA_ID;
它为fa返回以下值
1 | MALE, FEMALE | YES, NO
2 | FEMALE, MALE | NO, YES
3 | FEMALE, MALE | YES
4 | FEMALE, MALE | NO
我希望它显示空值,即
3 | FEMALE, MALE | YES, NULL
4 | FEMALE, MALE | NULL, NO
如何同时使用组concat和分隔符来实现相同的效果
2条答案
按热度按时间ddarikpa1#
注解:默认情况下,groupconcat以“,”分隔字段,因此,如果您愿意,可以省略它,ifnull(column,'default\utext'),这将替换所有null值默认情况下选择一个。
mw3dktmi2#
试着换掉那些
NULL
具有字符串文字的值'NULL'
: