注册 登录
编程论坛 MySQL论坛

从每个分类中取5条记录的SQL语句怎么写?

kyln 发布于 2008-08-08 10:52, 2112 次点击
程序代码:
CREATE TABLE article
(
    ID int auto_increment,
    title varchar(250) NOT NULL,
    type int not null,
    content text,
    date timestamp not null,
    primary key(id)
);

type表示文章的分类.
现在想从每个分类中取出最新发布的5条记录,用一个SQL语句能不能实现呀?
2 回复
#2
kyln2008-08-09 14:38
大家都看奥运会去了吗
#3
netstriker2008-08-10 18:40
我还未准备看奥运,我这是暂没有装mysql ,所以未验证语句是否可行,试一下  select * from (select * from article group by type) limit 0,5
1