从每个分类选择10条记录的sql语句
更新时间:2009年08月14日 17:38:41 作者:
下面是从每个分类读取10条记录的代码,非常的不错。不过性能就一般化了。
从每个分类选择10条记录
select a.* from Content a where a.log_ID in (select top 10 log_ID from Content where log_CateID = a.log_CateID order by log_ID desc) order by log_ID desc"
注意
Content 是新闻记录表
log_CateID 是分类字段
log_ID 关键字字段,自动增加的
复制代码 代码如下:
select a.* from Content a where a.log_ID in (select top 10 log_ID from Content where log_CateID = a.log_CateID order by log_ID desc) order by log_ID desc"
注意
Content 是新闻记录表
log_CateID 是分类字段
log_ID 关键字字段,自动增加的
相关文章
SQL Server2019数据库备份与还原脚本(批量备份)
本文主要介绍了SQL Server2019数据库备份与还原脚本,数据库可批量备份,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2021-11-11


最新评论