MySQL search and replace some text in a field

Kailash Singh

MySQL search and replace some text in a field

Published Sep 07,2022 by Kailash Singh

0 Comment     625 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 )