- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Deleting partial data from a field in MySQL?
To delete partial data, use UPDATE command along with REPLACE(). Let us first create a table −
mysql> create table DemoTable1583 -> ( -> GameDetails text -> ); Query OK, 0 rows affected (1.38 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1583 values('<GameName>=Candy</GameName>,<GamePrice>2000</GamePrice>'); Query OK, 1 row affected (0.53 sec) mysql> insert into DemoTable1583 values('<GameName>=Lucky29</GameName>,<GamePrice>10000</GamePrice>'); Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1583;
This will produce the following output −
+------------------------------------------------------------+ | GameDetails | +------------------------------------------------------------+ | <GameName>=Candy</GameName>,<GamePrice>2000</GamePrice> | | <GameName>=Lucky29</GameName>,<GamePrice>10000</GamePrice> | +------------------------------------------------------------+ 2 rows in set (0.00 sec)
Here is the query to delete partial data from a field in MySQL −
mysql> update DemoTable1583 set GameDetails=replace(GameDetails,'<GameName>=Candy</GameName>',''); Query OK, 1 row affected (0.38 sec) Rows matched: 2 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1583;
This will produce the following output −
+------------------------------------------------------------+ | GameDetails | +------------------------------------------------------------+ | ,<GamePrice>2000</GamePrice> | | <GameName>=Lucky29</GameName>,<GamePrice>10000</GamePrice> | +------------------------------------------------------------+ 2 rows in set (0.00 sec)
- Related Articles
- How to auto increment with 1 after deleting data from a MySQL table?
- How to remove partial text from value in MySQL?
- Delete partial data in MongoDB?
- Reorder keys after deleting a record from MySQL table?
- Need help in deleting duplicate columns from a table in MySQL?
- Appending data to a MySQL field that already has data in it?
- Does deleting row from view delete row from base table in MySQL?
- Converting a date in MySQL from string field?
- How to delete partial data in MongoDB?
- How to derive value of a field from another field in MySQL?
- How to copy data from one field to another on every row in MySQL?
- Reset the primary key to 1 after deleting all the data in MySQL?
- Remove seconds from time field in MySQL?
- Deleting records in MySQL using Nodejs
- How to select data in MySQL where a field has a minimum value?

Advertisements