songlv
(超级版主)
论坛元老
 
UID 73828
精华
0
积分 3021
帖子 693
金钱 3017 喜悦币
威望 0
人脉 4
阅读权限 90
注册 2006-5-22
状态 离线
|
[推荐阅读] 发现我真的挺穷...
1) 某内容管理系统中,表message有如下字段
id 文章id
title 文章标题
content 文章内容
category_id 文章分类id
hits 点击量
同样上述内容管理系统:表comment记录用户回复内容,字段如下
comment_id 回复id
id 文章id,关联message表中的id
comment_content 回复内容
现通过查询数据库需要得到以下格式的文章标题列表,并按照回复数量排序,回复最高的排在最前面
文章id 文章标题 点击量 回复数量
select id,title,content,category_id,hits,(select count(*) from comment c where m.id=c.id) as counts from message order by counts desc
|  不要跑 不要玩 不要看 不要 |
|