0

I have one mysql table with one of the column having some special text. I need to replace this text with new text.

data_table:

 Col1 Col2 Col3
  1    tc  That is nice word.
  2    tq  nice question.

I need to replace nice word with beautiful in table for Col3. How can i change it?

Regards

1

3 Answers 3

1
UPDATE MyTable SET Col3 = REPLACE(Col3 ,'nice','beautiful');
Sign up to request clarification or add additional context in comments.

7 Comments

above command works but when i replace some html tag Col3 becomes empty. UPDATE MyTable SET Col3 = REPLACE(Col3 ,'>','>');
Do you have a any records where Col3 is >? Do you have any sample data you can post?
;/li><li>This is first line.</li>
@Manish, here is the SQL Fiddle and SQL Fiddle that shows that it works. As you can see, the sub string is being found and replaced. The confusion may be coming from the fact that you are working with html markup and it may be automatically formatted accordingly.
@Manish, here is the SQL Fiddle and SQL Fiddle that shows it works with mediumtext as well. As long as it is a string it should work.
|
1

use mysql REPLACE(col, 'old value','newvalue')

Comments

0

to select =SELECT REPLACE(col3,'nice','beautiful') from table where col1 = '1'

to update = UPDATE table SET Col3 = REPLACE(Col3 ,'nice','beautiful')

IMHO.. CMIW

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.