WHILE indexchar <= charlength DO
SET charac = SUBSTRING(stringalpha,indexchar,1);
IF (serial_number LIKE CONCAT('%',charac,'%') OR name LIKE CONCAT('%',charac,'%'))
SET result = CONCAT(result,charac);
END IF;
SET indexchar = indexchar+1;
END WHILE