How to remove special characters by mysql custom function.

How to remove special characters by mysql custom function.

In this post we will give you information about How to remove special characters by mysql custom function.. Hear we will give you detail about How to remove special characters by mysql custom function.And 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 special characters from table field value. this function through you can also remove special 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 removeSpacialChar function:

CREATE FUNCTION 'removeSpacialChar'('in_str' varchar(4096)) RETURNS varchar(4096) CHARSET utf8

BEGIN

DECLARE out_str VARCHAR(4096) DEFAULT '';

DECLARE c VARCHAR(4096) DEFAULT '';

DECLARE pointer INT DEFAULT 1;

IF ISNULL(in_str) THEN

RETURN NULL;

ELSE

WHILE pointer

SET c = MID(in_str, pointer, 1);

IF (ASCII(c) >= 48 AND ASCII(c) = 65 AND ASCII(c) = 97 AND ASCII(c)

SET out_str = CONCAT(out_str, c);

ELSE

SET out_str = CONCAT(out_str, ' ');

END IF;

SET pointer = pointer + 1;

END WHILE;

END IF;

RETURN out_str;

END

Use With Select Query:

SELECT removeSpacialChar(users.name) FROM 'users'

Hope this code and post will helped you for implement How to remove special characters by mysql custom function.. 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

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

43  +    =  52

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US