【MySQL】每日一题2020-02-25

2020-02-25  本文已影响0人  每天要读书的Claire
create table t_0225 (hobby varchar(50))ENGINE=INNODB DEFAULT CHARSET=utf8;
insert into t_0225 values('篮球');
insert into t_0225 values('足球');
insert into t_0225 values ('羽毛球');
insert into t_0225 values('乒乓球');
mysql> select group_concat(hobby) as hobby from t_0225;
+-----------------------------------+
| hobby                             |
+-----------------------------------+
| 篮球,足球,羽毛球,乒乓球           |
+-----------------------------------+
1 row in set (0.00 sec)
mysql> select substring_index(substring_index(hobby,',',help_topic_id+1),',',-1) as hobby from t_0225 left join mysql.help_topic on (length(hobby)-length(replace(hobby,',',''))+1)>help_topic_id;
+-----------+
| hobby     |
+-----------+
| 篮球      |
| 足球      |
| 羽毛球    |
| 乒乓球    |
+-----------+
4 rows in set (0.00 sec)
上一篇下一篇

猜你喜欢

热点阅读