Home > Database > Mysql Tutorial > 从每个分类选择10条记录的sql语句

从每个分类选择10条记录的sql语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:58:46
Original
1775 people have browsed it

下面是从每个分类读取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 关键字字段,自动增加的
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template