Find and Replace a string in database table


There is SQL function named REPLACE()

Query is

UPDATE table_name SET field_name = REPLACE(field_name , ‘find string’, ‘replace with this string’);

For example

UPDATE post SET body = REPLACE(body , ‘sathia’, ‘sathia.s’);

In this example it replaces ‘sathia’ with ‘sathia.s’ in ‘body’ of ‘post’ table

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

2 Responses to Find and Replace a string in database table

  1. V.Ramachandran says:

    Nice post.
    Keep rocking…

  2. sathia27 says:

    ya . Thank u 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s