Sql function remove numeric characters from column example
In this post we will give you information about Sql function remove numeric characters from column example. Hear we will give you detail about Sql function remove numeric characters from column exampleAnd how to use it also give you demo for it if it is necessary.
Mysql custom fucntion is a very prety and intresting concept. In this posts i want to create one custom mysql function for remove numeric characters from table field value. this function through you can also remove numeric characters from string in mysql. in following sql query fire in your mysql or mssql database and check how it works. So, lets create function and how to use in select statement in sql query.
Create removeNumber function:
DROP FUNCTION IF EXISTS removeNumber;
CREATE FUNCTION removeNumber( str CHAR(32) ) RETURNS CHAR(16)
DECLARE i_val, len SMALLINT DEFAULT 1;
DECLARE ret CHAR(32) DEFAULT '';
DECLARE c CHAR(1);
SET len = CHAR_LENGTH( str );
SET c = MID( str, i_val, 1 );
IF c REGEXP '[[:alpha:]]' THEN
SET i_val = i_val + 1;
UNTIL i_val > len END REPEAT;
Use With Select Query:
SELECT removeNumber(users.name) FROM 'users'
Hope this code and post will helped you for implement Sql function remove numeric characters from column example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs