

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How MySQL REPLACE() function replaces strings in multiple records?
If we want to replace strings in multiple records then REPLACE() function must have the column name as 1st argument i.e. at the place of string. It means that, it will replace all the substring with another substring in that particular column. We can also use REPLACE() function with WHERE clause along with UPDATE statement to apply conditions. It is exhibit with the following example:
Example
mysql> Update Student set Name = REPLACE(Name, 'G','S') WHERE Subject LIKE '%Comp%'; Query OK, 2 rows affected (0.08 sec) Rows matched: 2 Changed: 2 Warnings: 0
The above query replaces strings in multiple records of Student table.
mysql> Select Name, Subject from Student; +---------+-----------+ | Name | Subject | +---------+-----------+ | Saurav | Computers | | Aarav | History | | Harshit | Commerce | | Saurav | Computers | | Yashraj | Math | +---------+-----------+ 5 rows in set (0.00 sec)
- Related Questions & Answers
- How can I use MySQL replace() to replace strings in multiple records?
- Replace records based on conditions in MySQL?
- Insert records from multiple tables in MySQL
- MySQL query to insert multiple records quickly
- Combine multiple text records to one in MySQL
- MySQL update multiple records in a single query?
- Find and replace a part of URL records in MySQL?
- Delete selective multiple records using MySQL DELETE query
- MySQL search and replace record from a list of records
- MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
- Function that only replaces character from string after specified appearances in JavaScript
- How can MySQL REPLACE() function be used with WHERE clause?
- How can MySQL find and replace the data with REPLACE() function to UPDATE the table?
- Concatenate Multiple Strings in Java.
- concat(), replace(), and trim() Strings in Java.
Advertisements