MySQL存储过程数组实现
MySQL存储过程数组实现:
- DELIMITER $$
- DROP PROCEDURE IF EXISTS `array`$$
- CREATE PROCEDURE `array`()
- BEGIN
- SET @array_content="www mysql com hcymysql blog 51cto com";
- SET @i=1;
- SET @count=CHAR_LENGTH(@array_content)-CHAR_LENGTH(REPLACE(@array_content,' ','')) + 1;
- -- 得出数组成员总数
- CREATE TABLE test.tmp(field1 VARCHAR(100));
- WHILE @i <= @count
- DO
- INSERT INTO test.tmp VALUES
- (SUBSTRING_INDEX(SUBSTRING_INDEX(@array_content,' ',@i),' ',-1));
- -- 依次插入每个成员
- SET @i=@i+1;
- END WHILE;
- END$$
- DELIMITER ;
测试:
相关推荐
Omega 2020-08-16
zjyzz 2020-08-16
minggehenhao 2020-07-28
zhaojp0 2020-06-27
zjuwangleicn 2020-06-25
wenjieyatou 2020-06-17
liaomingwu 2020-06-16
hungzz 2020-06-16
muzirigel 2020-06-14
gsmfan 2020-06-14
ncomoon 2020-06-14
xiaobaif 2020-06-13
Rain 2020-06-12
hanshangzhi 2020-06-12
talkingDB 2020-06-12
IBMRational 2020-06-09
snowguy 2020-06-01