Reputation: 3873
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?
Upvotes: 0
Views: 150
Reputation: 7304
Select id, REPLACE(text,'hello','hi') AS text from table;
It's somewhat database dependent, but that should work on most databases.
Upvotes: 0
Reputation: 5155
as seen in this article
update TABLE_NAME set
FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
Upvotes: 1