Sql function remove numeric characters from column exampleBy Hardik Savani | March 12, 2016 | | 1836 Viewer | Category : PHP MySql SQL MSSQL
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`
- How to import CSV file using mysql
- How to solve - you dont have permission to upload files in KCFinder ?
- How to increase throttle lockout time and max Login Attempts in Laravel 5?
- AngularJS - How to Capitalize the first letter of word Using filter?
- Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
- Laravel - How to get current URL in controller or view?
- Fixed - MassAssignmentException in model.php laravel 5?
- How to use DB transactions in laravel 5?