56,687
社区成员
发帖
与我相关
我的任务
分享
mysql> select length(replace('1,2,3,4,5',',',''));
+-------------------------------------+
| length(replace('1,2,3,4,5',',','')) |
+-------------------------------------+
| 5 |
+-------------------------------------+
1 row in set (0.00 sec)
mysql>
select SUBSTRING_INDEX('1,2,3,4,5',',',1),
SUBSTRING_INDEX(SUBSTRING_INDEX('1,2,3,4,5',',',2),',',-1),
SUBSTRING_INDEX(SUBSTRING_INDEX('1,2,3,4,5',',',3),',',-1),
SUBSTRING_INDEX(SUBSTRING_INDEX('1,2,3,4,5',',',4),',',-1),
SUBSTRING_INDEX(SUBSTRING_INDEX('1,2,3,4,5',',',5),',',-1);
insert into B(b_id,c_id)
select 1,id
from seq
where find_in_set(id,'1,2,3,4,5');
mysql> select 1,id
-> from seq
-> where find_in_set(id,'1,2,3,4,5');
+---+----+
| 1 | id |
+---+----+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
+---+----+
5 rows in set (0.00 sec)
mysql>