验证中...
Languages: SQL
Categories: 数据库相关
Latest update 2018-12-09 10:09
MySQL将字符串下划线转为驼峰的方法
Raw Copy
DELIMITER $$
CREATE
FUNCTION `dbname`.`underline2Camel`(column_name VARCHAR(60))
RETURNS VARCHAR(60)
BEGIN
DECLARE temp VARCHAR(60);
DECLARE i INT;
SET temp = column_name;
SET i = INSTR(temp, '_');
WHILE i > 0 DO
SET temp = CONCAT(SUBSTR(temp, 1, i - 1), UPPER(SUBSTR(temp, i + 1, 1)), IF(CHAR_LENGTH(temp) > (i + 1), SUBSTR(temp, i + 2), ''));
SET i = INSTR(temp, '_');
END WHILE;
RETURN temp;
END$$
DELIMITER ;

Comment list( 0 )

You need to Sign in for post a comment

Help Search