mysql 如何将多个字段的内容联合成一个字符串? 字段都是enum类型的,枚举变量是用汉字表示的!比如 enum('新闻','博客','论坛')。而我现在希望将同一条记录中几个这样的字段连接成一个字符串,如:"博客/供求/负面"如何做到? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select concat(col1,col2) from xxx 用CONCAT即可select concat('123',456,'博客/供求/负面') select concat('博客','/','供求','/','负面') mysql> create table t_netxuning ( -> id int, -> col1 enum('新闻','博客','论坛'), -> col2 enum('新闻','博客','论坛') -> );Query OK, 0 rows affected (0.45 sec)mysql> select * from t_netxuning;+------+------+------+| id | col1 | col2 |+------+------+------+| 1 | 新闻 | 博客 || 2 | 博客 | 论坛 || 3 | 论坛 | 新闻 |+------+------+------+3 rows in set (0.00 sec)mysql> select id,concat(col1,'/',col2) from t_netxuning;+------+-----------------------+| id | concat(col1,'/',col2) |+------+-----------------------+| 1 | 新闻/博客 || 2 | 博客/论坛 || 3 | 论坛/新闻 |+------+-----------------------+3 rows in set (0.00 sec)mysql> select group_concat(col1 SEPARATOR '/') from t_netxuning;+----------------------------------+| group_concat(col1 SEPARATOR '/') |+----------------------------------+| 新闻/博客/论坛 |+----------------------------------+1 row in set (0.00 sec)mysql> mysql存储过程参数可不可以带默认值 【未解决】mysql查询时不能使用别名查询 select中的if()函数里如何实现赋值?非常感谢! 求完整版VC++连接postgresql方法,求代码. MySQL有没有最大匹配某字符串的函数 关于MySQL的几个问题 ADO连接MYSQL出现灾难性故障!! mysql好像没有存储过程是吧? 如何解决mysql插入新纪录的重复问题 Mysql 1067 无法启动 SQL里怎样查询STUDENT表中姓名相同数据 复杂删除语句编译不能过
select concat('123',456,'博客/供求/负面')
-> id int,
-> col1 enum('新闻','博客','论坛'),
-> col2 enum('新闻','博客','论坛')
-> );
Query OK, 0 rows affected (0.45 sec)mysql> select * from t_netxuning;
+------+------+------+
| id | col1 | col2 |
+------+------+------+
| 1 | 新闻 | 博客 |
| 2 | 博客 | 论坛 |
| 3 | 论坛 | 新闻 |
+------+------+------+
3 rows in set (0.00 sec)mysql> select id,concat(col1,'/',col2) from t_netxuning;
+------+-----------------------+
| id | concat(col1,'/',col2) |
+------+-----------------------+
| 1 | 新闻/博客 |
| 2 | 博客/论坛 |
| 3 | 论坛/新闻 |
+------+-----------------------+
3 rows in set (0.00 sec)mysql> select group_concat(col1 SEPARATOR '/') from t_netxuning;
+----------------------------------+
| group_concat(col1 SEPARATOR '/') |
+----------------------------------+
| 新闻/博客/论坛 |
+----------------------------------+
1 row in set (0.00 sec)mysql>