SELECT group_concat(content separator '#'),wc,min(id) FROM `table` group by wc
SELECT ugr.`userId`,GROUP_CONCAT(roleId,',')AS roles,groupId FROM pmp_user_group_role ugr WHERE ugr.`groupId` = 'g000' AND ugr.`roleId` != '0000' AND ugr.`mark` = 0 AND ugr.`userId` IS NOT NULL GROUP BY ugr.userId
mysql默认会以‘,’来分隔多的值,若是想用其余的分隔符来分隔返回结果,好比指望返回值是这样的:1|2|3|4这能够用SEPARATOR来搞定。 mysql
做为GROUP_CONCAT函数参数的字段,如过返回值为string,则上面的sql语句已经没有问题,可是若是是number,则返回的GROUP_CONCAT(volumn)值为BLOB类型,须要作一下转化。 sql
select year,month GROUP_CONCAT(conv( oct( volumn ) , 8, 10 )) from magazine group by year,month order by year desc, month desc
上面的sql对volumn作了一个从8进制到10进制的转换,这样返回的就是一个字符串了。 函数