select col from tb where substring(col,1,1) in(1,'*') and substring(col,2,1) in(3,'*') and substring(col,3,1) in(8,'*') and substring(col,4,1) in(5,'*') and substring(col,5,1) in(9,'*') and substring(col,6,1) in(7,'*') and substring(col,7,1) in(4,'*')
declare @t table(col varchar(10)) insert @t select '2**5974' insert @t select '*3**9**' insert @t select '2*2597s' select col from @t where substring(col,1,1) in(2,'*') and substring(col,2,1) in(3,'*') and substring(col,3,1) in(8,'*') and substring(col,4,1) in(5,'*') and substring(col,5,1) in(9,'*') and substring(col,6,1) in(7,'*') and substring(col,7,1) in(4,'*')/* col ---------- 2**5974 *3**9** */
declare @t table(col varchar(10)) insert @t select '2**5974' insert @t select '*3**9**' insert @t select '2*2597s' select col from @t where col like '[2*][3*][8*][5*][9*][7*][4*]' /* col ---------- 2**5974 *3**9**(2 行受影响) */
substring(col,3,1) in(8,'*') and substring(col,4,1) in(5,'*') and substring(col,5,1) in(9,'*')
and substring(col,6,1) in(7,'*') and substring(col,7,1) in(4,'*')
insert @t select '2**5974'
insert @t select '*3**9**'
insert @t select '2*2597s'
select col from @t where substring(col,1,1) in(2,'*') and substring(col,2,1) in(3,'*') and
substring(col,3,1) in(8,'*') and substring(col,4,1) in(5,'*') and substring(col,5,1) in(9,'*')
and substring(col,6,1) in(7,'*') and substring(col,7,1) in(4,'*')/*
col
----------
2**5974
*3**9**
*/
insert @t select '2**5974'
insert @t select '*3**9**'
insert @t select '2*2597s'
select col
from @t
where col like '[2*][3*][8*][5*][9*][7*][4*]'
/*
col
----------
2**5974
*3**9**(2 行受影响)
*/