I need to assign AAA-BBB-CCC in 3 different MySQL variables.
Here's the unsuccessful code:
DELIMITER $$
USE `testdepot`$$
DROP PROCEDURE IF EXISTS `sp_test_dlr`$$
CREATE PROCEDURE `sp_test_dlr`(IN id VARCHAR(250),OUT temp1 VARCHAR(50)
,OUT temp2 VARCHAR(50),OUT temp3 VARCHAR(50))
BEGIN
DECLARE t1 VARCHAR(100);
DECLARE t2 VARCHAR(100);
DECLARE t3 VARCHAR(255);
SET @t1 = SUBSTRING_INDEX(id, '-', 1);
SET @t2 = SUBSTRING_INDEX(id, '-', -1);
SET @t3 = SUBSTRING_INDEX(id, '-', -1);
SELECT @t1 INTO temp1;
SELECT @t2 INTO temp2;
SELECT @t3 INTO temp3;
END$$
DELIMITER ;
How can I separate above AAA-BBB-CCC string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…