Database
SQL
Sql Function Remove Numeric Characters From Column Example
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.
- TAGS
- Query
- 4.5/5.0
- Last updated 08 September, 2022
- By Admin
Create removeNumber function:
DROP FUNCTION IF EXISTS removeNumber; DELIMITER | CREATE FUNCTION removeNumber( str CHAR(32) ) RETURNS CHAR(16) BEGIN DECLARE i_val, len SMALLINT DEFAULT 1; DECLARE ret CHAR(32) DEFAULT ''; DECLARE c CHAR(1); SET len = CHAR_LENGTH( str ); REPEAT BEGIN SET c = MID( str, i_val, 1 ); IF c REGEXP '[[:alpha:]]' THEN SET ret=CONCAT(ret,c); END IF; SET i_val = i_val + 1; END; UNTIL i_val > len END REPEAT; RETURN ret; END | DELIMITER ;
Use With Select Query:
SELECT removeNumber(users.name) FROM `users`
Categories
PHP
(5)
Codeigniter
(5)
Laravel
(3)
JS
(1)
Angular JS
(5)
Node JS
(5)
Vue JS
(4)
React JS
(6)
jQuery
(5)
Javascript
(3)
jQuery UI
(6)
Wordpress
(1)
Python
(5)
Database
(1)
MySql
(5)
Mongo DB
(1)
DBMS
(1)
SQL
(5)
HTML
(1)
HTML 5
(5)
CSS
(5)
Bootstrap
(5)
Ajax
(5)
JAVA
(1)
JSON
(5)
Ubuntu
(5)
Server
(5)
Git
(3)
Google
(1)
Google Map
(7)
Google API
(1)
Elastic Search
(1)
Apache
(1)
Installation
(1)