
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to replace special characters from 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)
- Related Articles
- MySQL query to remove special characters from column values?
- MySQL query to replace a column value
- MySQL query to retrieve only the column values with special characters?
- Append special characters to column values in MySQL
- MySQL query to select a specific string with special characters
- JavaScript regex - How to replace special characters?
- How to use special characters in column names with MySQL?
- MySQL query to keep only first 2 characters in column value and delete rest of the characters?
- Replace only a specific value from a column in MySQL
- MySQL query to split a column after specific characters?
- MySQL query to replace backslash from a varchar column with preceding backslash string values
- MySQL query to delete last two words from every column value
- MySQL query to fetch the maximum corresponding value from duplicate column values
- How to remove special characters from a database field in MySQL?
- How to replace all the special characters following another character – JavaScript?

Advertisements