
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Replace Special Characters in MySQL Column Value
Let us first create a table −
mysql> create table DemoTable1574 -> ( -> StudentCode varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1574 values('111_Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1574 values('______'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable1574 values('David_12345'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1574 values('______'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1574;
This will produce the following output −
+-------------+ | StudentCode | +-------------+ | 111_Carol | | ______ | | David_12345 | | ______ | +-------------+ 4 rows in set (0.00 sec)
Here is the query to replace −
mysql> update DemoTable1574 set StudentCode=replace(StudentCode,'______','Mike_007'); Query OK, 2 rows affected (0.38 sec) Rows matched: 4 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1574;
This will produce the following output −
+-------------+ | StudentCode | +-------------+ | 111_Carol | | Mike_007 | | David_12345 | | Mike_007 | +-------------+ 4 rows in set (0.00 sec)
Advertisements