2012-04-22 13 views
0

sqlを使用してフィールドの特定のテキストを置き換えるにはどうすればよいですか?クエリを使用してテキストを置き換える方法

例表:

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

手つかずの残りのテキストを残しながら、どのように私はフィールドtexthihelloを置き換えるでしょうか?

+0

[SQLで検索して置き換える]の可能な複製(http://stackoverflow.com/questions/421227/sql-to-search-and-replace-in-mysql) –

答えて

2
UPDATE YOUR_TABLE SET `text` = REPLACE(`text`, 'hello', 'hi') 
1

それは多少のデータベースに依存しますが、それはほとんどのデータベース上で動作するはずです。このarticle

update TABLE_NAME set 
FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’); 
0
Select id, REPLACE(text,'hello','hi') AS text from table; 

に見られるように。

関連する問題