Возможно
SET @X = 100200300;
SET @Y = 10;
select concat(substring(@x,1,3) + @y,substring(@x,4,3) + @y,substring(@x,7,3) + @y) x;
+-----------+
| x |
+-----------+
| 110210310 |
+-----------+
1 row in set (0.001 sec)
Если x неизвестной длины DROP PROCEDURE IF EXISTS P; DELIMITER $$ СОЗДАТЬ ПРОЦЕДУРУ p (
)
BEGIN
DECLARE counter INT DEFAULT 1;
set @x = '100200300400';
set @y = 10;
SET @OUT = '';
L:WHILE counter <= @x / 3 DO
#SELECT COUNTER;
IF @x is null or COUNTER > 10 THEN LEAVE L; END IF;
SET @OUT = CONCAT(@OUT,substring(@x,counter,3) + @y);
SET @X = REPLACE(@X,@out,'');
#select concat(substring(@x,counter,3) + @y,substring(@x,(counter +3),3) + @y) x;
SET COUNTER = COUNTER + 3;
END WHILE;
select @out;
END $$
DELIMITER ;
CALL P();
DELIMITER ;