在Sql中替换正则表达式

时间:2014-02-10 09:06:39

标签: mysql regex

我在Sql中有一个表

表1:

========================================

ID     Text
1      i am a boy
2      boy!what are you doing?
3      that boy is nice
4      He is a Boy and go to school

========================================

我想替换word boy(不区分大小写)。比如替换男孩然后输出显示

表2:

========================================

ID     Text
1      i am a Man
2      Man!what are you doing?
3      that Man is nice
4      He is a Boy and go to school

========================================

我需要在Sql中编写什么Query来执行此操作

2 个答案:

答案 0 :(得分:1)

SELECT id, REPLACE( text, 'boy', 'man' )

FROM table1

答案 1 :(得分:0)

您可以使用以下替换命令替换:

Update tablename Set Text = replace(Text, 'boy', 'Man');