Dear Mates, Please click the ads to support us.
Tutorial

MySQL search and replace some text in a field

Kailash Singh Sep 07, 2022 1996 Views
Kailash Singh

MySQL search and replace some text in a field Share

Published Sep 07, 2022 by Kailash Singh 0 Comments 1996 Views

In this tutorial, we are going to teach. How to Search and Replace some text in a field using MySQL.

 

Definition and Usage

The REPLACE() function replaces all occurrences of a substring within a string, with a new substring.

Note: This function performs a case-sensitive replacement.

 

Syntax:

UPDATE table_name SET field = replace(field, 'string-to-find', 'string-that-will-replace-it');

 

Example: 

UPDATE fruit SET fruit_name = replace(fruit_name, 'appel', 'apple');

 

Comments 0