码迷,mamicode.com
首页 > 数据库 > 详细

SQL中replace函数

时间:2015-01-06 11:45:48      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:

昨天做修改操作时用到了replace函数

--备份表
create table ac01_20150105 as select * from ac01;
create table ac01_dy_20150105 as select * from ac01_dy;
create table cjscrz_20150105 as select * from cjscrz;




--更新基本信息
update ac01 t set t.yhmc = replace(t.yhmc,‘95580‘,‘96288‘) where t.photo_path like ‘%82_SBK_3_41100023_6000_20141225_4%‘ and t.yhmc = ‘95580‘;
update ac01_dy t set t.yhmc = replace(t.yhmc,‘95580‘,‘96288‘) where t.photo_path like ‘%82_SBK_3_41100023_6000_20141225_4%‘ and t.yhmc = ‘95580‘;

--更新采集上传日志
update cjscrz t set t.yl1 = replace(t.yl1,‘95580‘,‘96288‘) where t.scpc like ‘%82_SBK_3_41100023_6000_20141225_4%‘ and t.yl1 like ‘%95580%‘; 

replace函数

用第三个表达式替换第一个字符串表达式中出现的所有第二个给定字符串表达式。

语法

REPLACE ( ‘string_expression1‘ , ‘string_expression2‘ , ‘string_expression3‘ )

参数

string_expression1

待搜索的字符串表达式。string_expression1 可以是字符数据或二进制数据。

string_expression2

待查找的字符串表达式。string_expression2 可以是字符数据或二进制数据。

string_expression3

替换用的字符串表达式。string_expression3 可以是字符数据或二进制数据。

返回类型

如果 string_expression(1、2 或 3)是支持的字符数据类型之一,则返回字符数据。如果 string_expression(1、2 或 3)是支持的 binary 数据类型之一,则返回二进制数据。

SQL中replace函数

标签:

原文地址:http://www.cnblogs.com/2012knight/p/4205501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!