update 追加一个字段的内容,或替换一个字段里面某些 字符

一:

使用REPLACE更新某表中某个字段详细内容

update `表名` set 字段名 =replace(字段名, '查找的内容','更改的内容') where 字段名 like '%查找的内容%';

update shangpin set click_url=replace(click_url,'21508360','1111111111') where click_url like '%21508360%';


二:

mysql concat追加字符串后追加update表名set字段名=concat(字段名,"str

mysql concat追加字符串

  1.后追加update 表名 set 字段名 = concat(字段名,"string")    2.  前追加update 表名 set 字段名 = concat("string",字段名)

         UPDATE  log_201408_35  SET `return_content`=CONCAT (`return_content`,' world') WHERE id=1


微博关注代码


<iframe allowtransparency="" border="0" frameborder="0" height="22" marginheight="0" marginwidth="0" scrolling="no" src="http://widget.weibo.com/relationship/followbutton.php?width=200&height=22&uid=3211505780&style=5&btn=red&dpc=1" style="width: 64px; height: 22px;" width="200"></iframe>

Mysql更新(substring函数和concat函数的使用)



在custom表中有一个tariffurl的值中有如下情况:

uploadfiles ariff2007031172720306698.jpg以及uploadfiles ariff2007031172720306690.jpg;uploadfiles ariff2007031172720306691.jpg形式

要更改成uploadfiles/tariff/200703/1172720306698.jpg及uploadfiles/tariff/200703/1172720306690.jpg;uploadfiles/tariff200703/1172720306691.jpg形式

可以综合利用substring函数和cancat函数来实现,步骤如下:

1、update custom set tariffurl=concat('uploadfiles/tariff/200703/',substring(tariffurl,24)) where tariffurl like 'uploadfiles ariff200703%'


2、update custom set tariffurl=concat(substring(tariffurl,1,55),'/tariff/200703/',substring(tariffurl,68))
where tariffurl like 'uploadfiles/tariff/200703/%' and tariffurl like'%;uploadfiles %'


substring(filed,m):截取filed字段从第m个字符开始到结束的字符串;

substring(filed,m,n):截取filed字段从第m个字符开始的长度为n的字符串;

cancat(string1,sting2,……):将string1、string2, ……字符串连接起来。



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值