"select Top 6 ID,Title from tb_Article as A where ID<>" + iID + " and exists(select * from (select SUBSTRING('" + strTags + "',number,CHARINDEX(',','" + strTags + "' + ',',number)-number) as v from master.dbo.spt_values where type = 'p' AND SUBSTRING(',' + '" + strTags + "',number,1)=',') AS T where CHARINDEX(v,A.Title)>0 or CHARINDEX(v,A.Tags)>0)"这是一个按照标签显示数据的语句!strTags=“中国,俄国”要求按照标签的先后顺序显示高手指导
declare @a table (a int null,b varchar(10) null)
insert into @a
select 1,'俄国' union all
select 2,'中国' union all
select 3,'美国' union all
select 4,'法国'select * from @a order by charindex(b,'中国,法国,美国,俄国') asc--a b
--2 中国
--4 法国
--3 美国
--1 俄国