select * from tb where charindex('a',col)>0 and charindex('c',col)>0
like "*a*c*" or "*c*a*"
if object_id('tb') is not null drop table tb go create table tb([col] varchar(10)) insert tb select 'abcd' union all select 'adec' union all select 'ehakc' union all select 'rtathc' union all select 'ifdas' go select * from tb where charindex('a',col)>0 and charindex('c',col)>0 /* col ---------- abcd adec ehakc rtathc(4 行受影响) */
select * from tb where col like '%a%c%' or col like '%c%a%'
select * from tb where charindex('a',col)>0 and charindex('c',col)>0 or like "*a*c*" or "*c*a*"
go
create table tb([col] varchar(10))
insert tb select 'abcd'
union all select 'adec'
union all select 'ehakc'
union all select 'rtathc'
union all select 'ifdas'
go
select * from tb where charindex('a',col)>0 and charindex('c',col)>0
/*
col
----------
abcd
adec
ehakc
rtathc(4 行受影响)
*/
select * from tb where col like '%a%c%' or col like '%c%a%'
select * from tb where charindex('a',col)>0 and charindex('c',col)>0
or
like "*a*c*" or "*c*a*"
良好;一般;优秀;差;极差
一般;差;极差
良好;差;优秀
一般;差
良好;优秀
良好;一般;优秀
找出所有同时包"良好"和"优秀"的记录,除了LIKE之外,还有没有别的方法,另外,如果用LIKE在记录多的情况下会不会变慢,谢谢