mySQL中replace的用法
来源:互联网 发布:egd网络黄金 编辑:程序博客网 时间:2024/05/15 12:22
mysql replace实例说明:
UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def');
REPLACE(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被 to_str替换,然后返回这个字符串
这个函数用来批量替换数据中的非法关键字是很有用的!如下例子:
例1:UPDATE BBSTopic SET tcontents = replace(replace(tcontents,'共产党','') ,'找死','') where tcontents like '%共产党%' or tcontents like '%找死%'
例2:UPDATE typetable SET type_description=REPLACE(type_description,'360','http://www.jb51.net');
mysql replace用法
1.replace into
replace into table (id,name) values('1','aa'),('2','bb')
此语句的作用是向表table中插入两条记录。如果主键id为1或2不存在
就相当于
insert into table (id,name) values('1','aa'),('2','bb')
如果存在相同的值则不会插入数据
2.replace(object,search,replace)
把object中出现search的全部替换为replace
select replace('www.jb51.net','w','Ww')--->WwWwWw.jb51.net
例:把表table中的name字段中的aa替换为bb
update table set name=replace(name,'aa','bb')
UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def');
REPLACE(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被 to_str替换,然后返回这个字符串
这个函数用来批量替换数据中的非法关键字是很有用的!如下例子:
例1:UPDATE BBSTopic SET tcontents = replace(replace(tcontents,'共产党','') ,'找死','') where tcontents like '%共产党%' or tcontents like '%找死%'
例2:UPDATE typetable SET type_description=REPLACE(type_description,'360','http://www.jb51.net');
mysql replace用法
1.replace into
replace into table (id,name) values('1','aa'),('2','bb')
此语句的作用是向表table中插入两条记录。如果主键id为1或2不存在
就相当于
insert into table (id,name) values('1','aa'),('2','bb')
如果存在相同的值则不会插入数据
2.replace(object,search,replace)
把object中出现search的全部替换为replace
select replace('www.jb51.net','w','Ww')--->WwWwWw.jb51.net
例:把表table中的name字段中的aa替换为bb
update table set name=replace(name,'aa','bb')
0 0
- mysql中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mySQL中replace的用法
- mysql 中substring和replace的用法
- MySQL中REPLACE INTO语句的用法
- MYSQL中REPLACE命令的用法
- MYSQL中replace into的用法
- MYSQL中replace into的用法
- mysql中replace函数的用法
- MYSQL中replace into的用法
- MySQL中REPLACE INTO语句的用法
- (4.3.1.5)【项目一】子Fragment之NineGong和自定义的异步任务
- 解决使用Eclipse中调用javadoc的问题
- 随机函数
- Python做统计计算
- ViewPager实现页卡的最新方法--简洁的TabLayout(谷歌支持包)
- mySQL中replace的用法
- 2012年5月SAT香港真题解析
- jni 简介
- 语法错误 : 缺少“;”(在“<”的前面)
- android的activitygroup使用
- Unity自定义数据流
- 转载 httpclient 上传、下载文件
- Android的LinearLayout.getLayoutParams().width 和 LinearLayout.getWidth() 的区别
- 静态方法的线程安全