有这样一些字符串,比如:
001,002,003,004,005,006
001,002,005
002,006,007
005,006
008
001,005,006,009每个字符串用逗号隔开。
现在。
1、如果我们输入002,003 ,它自动找到最相似的 001,002,003,004,005,006
2、如果我们输入001,002,它自动找到
001,002,003,004,005,006
001,002,0053、如果输入002,那么找到的是
001,002,003,004,005,006
001,002,005
002,006,0074、如果输入的是001,005,那么现实的是
001,002,003,004,005,006
001,002,005
001,005,006,009
明白我的意思了吗?
谢谢。
001,002,003,004,005,006
001,002,005
002,006,007
005,006
008
001,005,006,009每个字符串用逗号隔开。
现在。
1、如果我们输入002,003 ,它自动找到最相似的 001,002,003,004,005,006
2、如果我们输入001,002,它自动找到
001,002,003,004,005,006
001,002,0053、如果输入002,那么找到的是
001,002,003,004,005,006
001,002,005
002,006,0074、如果输入的是001,005,那么现实的是
001,002,003,004,005,006
001,002,005
001,005,006,009
明白我的意思了吗?
谢谢。
我想了很多天都没搞定。向你学习,向你靠齐。虽然很难。呵呵
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([col] varchar(23))
insert [tb]
select '001,002,003,004,005,006' union all
select '001,002,005' union all
select '002,006,007' union all
select '005,006' union all
select '008' union all
select '001,005,006,009'
---查询---
declare @s varchar(8000), @sql varchar(8000)
set @s='001,005'set @s='col like ''%'+replace(@s,',','%'' and col like ''%')+'%'''set @sql='select * from tb where '+@s--print @sqlexec (@sql)---结果---
col
-----------------------
001,002,003,004,005,006
001,002,005
001,005,006,009