该需求可用SQL标签实现:以江苏省为例(基于文章系统KS_Article)
SQL语句:
- Select Top 15 id,tid,title,adddate,City From KS_Article a Where a.id In(Select Top 1 id From Ks_Article Where City=a.City) And a.Verific=1 And a.Deltf=0 And a.Province='江苏省' Order By a.id Desc
循环体:
根据实际情况自行写代码就可以了
效果:
具有推荐属性的一篇文章:
SQL:
- Select Top 15 id,tid,title,adddate,City From Ks_Article a Where a.id In(Select Top 1 id From KS_Article Where City=a.City) And a.Verific=1 And a.Deltf=0 And a.Recommend=1 And a.Province='江苏省' Order By a.id Desc
每个城市最新的一篇文章:
SQL:
- Select Top 15 id,tid,title,adddate,City From Ks_Article a Where a.id In(Select Top 1 id From KS_Article Where City=a.City Order By adddate Desc) And a.Verific=1 And a.Deltf=0 And a.Province='江苏省' Order By a.id Desc
每个栏目只调用一条文章 类似这样需求的和上面SQL语句类似,语句类似这样:
- Select Top 10 id,Tid,Title,Adddate From KS_Article a Where a.id In(Select Top 1 id From KS_Article Where Tid=a.Tid) And a.Verific=1 And a.Deltf=0 Order By a.id Desc