• Mysql获取字符串中的数字函数方法和调用


    CREATE FUNCTION GetNum (Varstring varchar(50))
    RETURNS varchar(30)
    BEGIN
    DECLARE v_length INT DEFAULT 0;
    DECLARE v_Tmp varchar(50) default '';
    set v_length=CHAR_LENGTH(Varstring);
    WHILE v_length > 0 DO
    IF (ASCII(mid(Varstring,v_length,1))>47 and ASCII(mid(Varstring,v_length,1))<58 ) THEN
    set v_Tmp=concat(v_Tmp,mid(Varstring,v_length,1));
    END IF;
    SET v_length = v_length - 1;
    END WHILE;
    RETURN REVERSE(v_Tmp);
    END;

    调用函数:

    select GetNum(字段) from table;-- GetNum中的字段名不需要用引号括起来

  • 相关阅读:
    BZOJ 3522 Hotel
    BZOJ 1864 三色二叉树
    396595
    CodeForces
    CodeForces
    CodeForces
    E. 数字串
    算术基本定理总结
    Cyclic Nacklace 杭电3746
    Period
  • 原文地址:https://www.cnblogs.com/wjm956/p/6605842.html
Copyright © 2020-2023  润新知