0

How do I replace certain text in a field using sql?

Example Table:

id               text
-------------------------------
1        hello my name is keven
2        hello my name is steve
3        hi my name is sam

How would I replace hello with hi in the field text while leaving the remaining text untouched?

1

3 Answers 3

2
UPDATE YOUR_TABLE SET `text` = REPLACE(`text`, 'hello', 'hi')
Sign up to request clarification or add additional context in comments.

Comments

1

as seen in this article

update TABLE_NAME set 
FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);

Comments

0
Select id, REPLACE(text,'hello','hi') AS text from table;

It's somewhat database dependent, but that should work on most databases.

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.