有一表ab内容如下
id name sex year
1 1 2011
2 ddd 0 2012
3 1 2011
4 1 2011
5 ggg 0 2012
6 1 2011
7 fff 1 2011
8 ggg 0 2012
9 1 2011
10 aaa 1 2000
11 1 2011查找结果为
count(id),group_concat(niu)
11 ,aaa,ddd,,,ggg,,fff,ggg,,aaa,这是我的语句:select count(id),group_concat(name) from ab
找出的结果里含有太多的逗号了,怎么去掉它啊?
理想的结果为:
count(id),group_concat(name)
11 aaa,ddd,ggg,fff,ggg,,aaa
id name sex year
1 1 2011
2 ddd 0 2012
3 1 2011
4 1 2011
5 ggg 0 2012
6 1 2011
7 fff 1 2011
8 ggg 0 2012
9 1 2011
10 aaa 1 2000
11 1 2011查找结果为
count(id),group_concat(niu)
11 ,aaa,ddd,,,ggg,,fff,ggg,,aaa,这是我的语句:select count(id),group_concat(name) from ab
找出的结果里含有太多的逗号了,怎么去掉它啊?
理想的结果为:
count(id),group_concat(name)
11 aaa,ddd,ggg,fff,ggg,,aaa
解决方案 »
- 在OA系统数据升级时,MYSQL报错,代码是#1242
- 散分了,第一次用postgreSQL,求科普各种下限问题
- 关于大量读写操作造成的问题,如何规避
- 这条语句,为什么死活要 “ Using filesort”
- 新手问题
- 关于MYSQL的transaction
- 哪里可以有MY SQL的下载,还有MY SQL现在收费吗?最好推荐本my SQL比较经典的书
- 如何在RH Linux9用源码安装MySQL4 ?
- 求在mysql中的一条sql语句
- mysql和Access、sql server的优缺点?
- 在mysql 的存储过程中如何实现with nolock功能
- 为什么select count(主键) from table xxx;比select count(*) from table xxx;效率要高?
select count(id),group_concat(name) from ab where name is not null
select count(*), substring_index(GROUP_CONCAT(name order by name desc),',,',1) from ab;