返回四条记录可以吗?
--存储过程
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"}')
mysql> SELECT
-> SUBSTRING('G3_555', INSTR('G3_555', '_') + 1);
+------------------------------------------------+
| SUBSTRING('G3_555', INSTR('G3_555', '_') + 1) |
+------------------------------------------------+
| 555 |
+------------------------------------------------+
1 row in set (0.00 sec) 真是麻烦啊 哈哈 不过还是完成了 希望不辱使命。
mysql> SELECT
-> 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"}')
大q手机怎么拆开后盖换卡