关于’
如果字段中又有 ' '和 '的字符串,我只想查出有 '的怎么查?
------解决方案--------------------create table #t1
(g1 char(2),
g2 varchar(10))
insert into #t1
select 'a ', ' ' 'adfasdf '
union all select 'b ', 'b ' 'c '
union all select 'c ', 'cd ' ' '
union all select 'd ', 'a ' ' ' 'b '
select *
from #t1
where g2= 'b ' 'c '
select * from #t1
where g2 like '% ' '% '
and g2 not like '% ' ' ' '% '
drop table #t1
============
结果:
(所影响的行数为 4 行)
g1,g2
b ,b 'c
(所影响的行数为 1 行)
g1,g2
a , 'adfasdf
b ,b 'c
c ,cd '
(所影响的行数为 3 行)