MySql中截取字符串中的某几个字符
{"cid":"1","configid":"1","jobtype":"android","installerid":"1"}截到4个字符串1,1,android,1求...
{"cid": "1","configid": "1","jobtype": "android","installerid": "1"}截到4个字符串1,1,android,1
求大神,能快速解决,急用! 展开
求大神,能快速解决,急用! 展开
5个回答
展开全部
返回四条记录可以吗?
--存储过程
create PROCEDURE `sp_print_result`(
IN f_string varchar(1000)
)
BEGIN
declare cnt int default 0;
declare i int default 0;
DECLARE tempstr varchar(100);
set f_string=REPLACE(f_string,'{','');
set f_string=REPLACE(f_string,'}','');
set f_string=REPLACE(f_string,'"','');
drop table if exists tmp_print;
create temporary table tmp_print (item VARCHAR(50) null);
while length(f_string)>0
do
set tempstr= SUBSTRING_INDEX(f_string,',',1);
set f_string = SUBSTR(f_string,LENGTH(tempstr)+2);
insert into tmp_print(item) values ( SUBSTR(tempstr,LENGTH(SUBSTRING_INDEX(tempstr,':',1))+2));
end while;
select * from tmp_print;
END
---调用
call sp_print_result( '{"cid": "1","configid": "1","jobtype": "android","installerid": "1"}')
2014-03-05
展开全部
mysql> SELECT
-> SUBSTRING('G3_555', INSTR('G3_555', '_') + 1);
+------------------------------------------------+
| SUBSTRING('G3_555', INSTR('G3_555', '_') + 1) |
+------------------------------------------------+
| 555 |
+------------------------------------------------+
1 row in set (0.00 sec) 真是麻烦啊 哈哈 不过还是完成了 希望不辱使命。
-> SUBSTRING('G3_555', INSTR('G3_555', '_') + 1);
+------------------------------------------------+
| SUBSTRING('G3_555', INSTR('G3_555', '_') + 1) |
+------------------------------------------------+
| 555 |
+------------------------------------------------+
1 row in set (0.00 sec) 真是麻烦啊 哈哈 不过还是完成了 希望不辱使命。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-05
展开全部
mysql> SELECT
-> SUBSTRING('G3_555', INSTR('G3_555', '_') + 1);
+------------------------------------------------+
| SUBSTRING('G3_555', INSTR('G3_555', '_') + 1) |
+------------------------------------------------+
| 555 |
+------------------------------------------------+
1 row in set (0.00 sec)
-> SUBSTRING('G3_555', INSTR('G3_555', '_') + 1);
+------------------------------------------------+
| SUBSTRING('G3_555', INSTR('G3_555', '_') + 1) |
+------------------------------------------------+
| 555 |
+------------------------------------------------+
1 row in set (0.00 sec)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
返回四条记录可以吗?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--存储过程
create PROCEDURE `sp_print_result`(
IN f_string varchar(1000)
)
BEGIN
declare cnt int default 0;
declare i int default 0;
DECLARE tempstr varchar(100);
set f_string=REPLACE(f_string,'{','');
set f_string=REPLACE(f_string,'}','');
set f_string=REPLACE(f_string,'"','');
drop table if exists tmp_print;
create temporary table tmp_print (item VARCHAR(50) null);
while length(f_string)>0
do
set tempstr= SUBSTRING_INDEX(f_string,',',1);
set f_string = SUBSTR(f_string,LENGTH(tempstr)+2);
insert into tmp_print(item) values ( SUBSTR(tempstr,LENGTH(SUBSTRING_INDEX(tempstr,':',1))+2));
end while;
select * from tmp_print;
END
---调用
call sp_print_result( '{"cid": "1","configid": "1","jobtype": "android","installerid": "1"}')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--存储过程
create PROCEDURE `sp_print_result`(
IN f_string varchar(1000)
)
BEGIN
declare cnt int default 0;
declare i int default 0;
DECLARE tempstr varchar(100);
set f_string=REPLACE(f_string,'{','');
set f_string=REPLACE(f_string,'}','');
set f_string=REPLACE(f_string,'"','');
drop table if exists tmp_print;
create temporary table tmp_print (item VARCHAR(50) null);
while length(f_string)>0
do
set tempstr= SUBSTRING_INDEX(f_string,',',1);
set f_string = SUBSTR(f_string,LENGTH(tempstr)+2);
insert into tmp_print(item) values ( SUBSTR(tempstr,LENGTH(SUBSTRING_INDEX(tempstr,':',1))+2));
end while;
select * from tmp_print;
END
---调用
call sp_print_result( '{"cid": "1","configid": "1","jobtype": "android","installerid": "1"}')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-05
展开全部
大q手机怎么拆开后盖换卡
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询