
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
Find and Replace Special Characters in MySQL
For this, use SET yourColumnName = NULL as in the below syntax −
update yourTableName set yourColumnName=NULL where yourColumnName=yourValue;
Let us first create a table −
mysql> create table DemoTable1914 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Code varchar(20) )AUTO_INCREMENT=1001; Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1914(Code) values('John101'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1914(Code) values('234David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1914(Code) values('100_Mike'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1914;
This will produce the following output −
+------+----------+ | Id | Code | +------+----------+ | 1001 | John101 | | 1002 | 234David | | 1003 | 100_Mike | +------+----------+ 3 rows in set (0.00 sec)
Here is the query to find a value and replace with NULL −
mysql> update DemoTable1914 set Code=NULL where Code='100_Mike'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1914;
This will produce the following output −
+------+----------+ | Id | Code | +------+----------+ | 1001 | John101 | | 1002 | 234David | | 1003 | NULL | +------+----------+ 3 rows in set (0.00 sec)
Advertisements