SQL LIKE????????????????
???????????? ???????[ 2012/10/10 10:59:08 ] ????????
?????洢??????????????£?
GO CREATE function Get_StrArrayLength ( @str varchar(1024)?? --?????????? @split varchar(10) --?????? ) returns int as begin declare @location int declare @start int declare @length int set @str=ltrim(rtrim(@str)) set @location=charindex(@split??@str) set @length=1 while @location<>0 begin set @start=@location+1 set @location=charindex(@split??@str??@start) set @length=@length+1 end return @length end GO CREATE function Get_StrArrayStrOfIndex ( @str varchar(1024)?? --?????????? @split varchar(10)?? --?????? @index int --????????? ) returns varchar(1024) as begin declare @location int declare @start int declare @next int declare @seed int set @str=ltrim(rtrim(@str)) set @start=1 set @next=1 set @seed=len(@split) set @location=charindex(@split??@str) while @location<>0 and @index>@next begin set @start=@location+@seed set @location=charindex(@split??@str??@start) set @next=@next+1 end if @location =0 select @location =len(@str)+1 --????????????????1?????????????????? 2????????д?????????????while?????@location?0???????????????????????????? return substring(@str??@start??@location-@start) end GO CREATE PROCEDURE proc_Common_SuperLike --??????????????????? @primaryKeyName varchar(999)?? --????????? @talbeName varchar(999)?? --?????????????????????????????? @contentFieldName varchar(999)?? --???????????(TOP *)???????????????????? @selectNumber varchar(999)?? --??????????? @splitString varchar(999)?? --?????????????? @words varchar(999) AS declare @sqlFirst varchar(999) declare @sqlCenter varchar(999) declare @sqlLast varchar(999) BEGIN set @sqlCenter='' declare @next int set @next=1 while @next<=dbo.Get_StrArrayLength(@words??@splitString) begin --????sql???????(?м???) set @sqlCenter = @sqlCenter+'SELECT '+@primaryKeyName+'FROM '+@talbeName+'WHERE '+@contentFieldName+'like ''%'+dbo.Get_StrArrayStrOfIndex(@words??@splitString??@next)+'%'' UNION ALL ' set @next=@next+1 end --????sql????м???????????????? set @sqlCenter=left(@sqlCenter??(len(@sqlCenter)-10)) --????sql??儷????? set @sqlFirst='SELECT TOP '+@selectNumber+''+@primaryKeyName+'??COUNT(*) AS showCout FROM (' --????sql????β???? set @sqlLast=') AS t_Temp GROUP BY '+@primaryKeyName+' ORDER BY showCout DESC' --????????sql???????? execute(@sqlFirst+@sqlCenter+@sqlLast) END |
?????????????
executeproc_Common_SuperLike 'id'??'t_test'??'content'??'20'??'|'??'i|o|c'
????id???????????????
????t_test??????
????content???????????????
????20???20???????????????????????????
????|????????????
????i|o|c?????i??o??c?????????????|????
???????????洢??????????????????????????????????????????????в???£???????????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????????SQL???SQL??й????е????????????mysql?????????????SQL??????????????mysql????? distinct?÷?MySQL?н???????????з??Mysql????????????????sql server 2000??????????????MySQL Cluster??δ??????????????SQL Server???????????????????λ?????PHP??SQL????????????????????????????SQL??????????SQLд?????SQL Server????????????????????????????????????SQL?????Pythonд???NoSQL?????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????