Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
MySQL query to remove special characters from column values?
Let us first create a table −
mysql> create table DemoTable -> ( -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('STU#123');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('STU#567');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('STU#98494');
Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-----------+ | StudentId | +-----------+ | STU#123 | | STU#567 | | STU#98494 | +-----------+ 3 rows in set (0.00 sec)
Following is the query to remove special characters −
mysql> update DemoTable -> set StudentId=replace(StudentId,'#',''); Query OK, 3 rows affected (0.13 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-----------+ | StudentId | +-----------+ | STU123 | | STU567 | | STU98494 | +-----------+ 3 rows in set (0.00 sec)
Advertisements
