在项目中有这样一个需求:评论列表按照点赞数由高到低显示前3条,其他按照时间顺序来排列
2条回答 默认 最新
- Kevin.Y.K 2019-12-05 10:41关注
第一次查询点赞数前三的ID: select id from t_comment order by dz_num desc limit 0,3 第二次关联查询 select *, 1 as isTop from t_comment where id in (3,4,5) union all select *, 0 as isTop from comment where id not in (3,4,5) order by isTop desc, create_time desc
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报