有一个字段里全都是这样的数据
pdf1/dxj_2005_001/14/06/111.pdf
pdf1/dxj_2005_001/14/06/112.pdf
pdf1/dxj_2005_001/14/06/113.pdf
pdf2/dxj_2005_001/14/06/114.pdf
pdf2/dxj_2005_001/14/06/115.pdf我想 搜索出包含“pdf1/dxj_2005_001/”的所有数据 然后把另外一个字段设置成 “dxj_2005_001”update tablename set aaa='dxj_2005_001' where bbb like 'pdf1/dxj_2005_001/%'
我知道这样写是不行的,网上也有说用escape之类的进行转义才行,但试了半天也不行,哪位大侠帮着看看应该怎样写呀
pdf1/dxj_2005_001/14/06/111.pdf
pdf1/dxj_2005_001/14/06/112.pdf
pdf1/dxj_2005_001/14/06/113.pdf
pdf2/dxj_2005_001/14/06/114.pdf
pdf2/dxj_2005_001/14/06/115.pdf我想 搜索出包含“pdf1/dxj_2005_001/”的所有数据 然后把另外一个字段设置成 “dxj_2005_001”update tablename set aaa='dxj_2005_001' where bbb like 'pdf1/dxj_2005_001/%'
我知道这样写是不行的,网上也有说用escape之类的进行转义才行,但试了半天也不行,哪位大侠帮着看看应该怎样写呀
update tablename set aaa='dxj_2005_001' where charindex('pdf1/dxj_2005_001/',bbb)=1
update tablename set aaa='dxj_2005_001' where charindex(''pdf1/dxj_2005_001/',bbb)>0
update tablename set aaa='dxj_2005_001' where bbb like 'pdf1[/]dxj_2005_001[/]%'
create table t1
(
name varchar(50)
)
insert into t1
select 'pdf1/dxj_2005_001/14/06/111.pdf' union all
select 'pdf1/dxj_2005_001/14/06/112.pdf' union all
select 'pdf1/dxj_2005_001/14/06/113.pdf' union all
select 'pdf2/dxj_2005_001/14/06/114.pdf' union all
select 'pdf2/dxj_2005_001/14/06/115.pdf'
select * from t1select * from t1 where name like 'pdf1/dxj_2005_001/%'-------------------------
name
pdf1/dxj_2005_001/14/06/111.pdf
pdf1/dxj_2005_001/14/06/112.pdf
pdf1/dxj_2005_001/14/06/113.pdf是可以直接查询出来的。