Mysql group_concat ignoring empty row column

The MYSQL group_concat () function by default ignores null columns, but does not ignore empty row columns. I have a field of type mediumtext, not null. When I use the group_concat function, the request generates an unwanted ",," this type of value. How can i avoid this? Thank you in advance for your precious time.

+6
source share
2 answers

Move empty string to null:

NULLIF(column1,'') 
+7
source

Use GROUP_CONCAT with IF(expr1,expr2,expr3) , suppose you want concat column1 :

 GROUP_CONCAT(IF(column1='', null, column1)) 
+1
source

Source: https://habr.com/ru/post/978373/


All Articles