mysql对数据进⾏分批_mysql如何分批读取数据
情景是数据库⾥有⼀系列的post(新闻类),现在想根据post表中有的post_date(时间),view(浏览数量),或者post_like表的likeCount进⾏排序,并分批读取数据,limit在25
⽐如说post_date:
SELECT post.*, user.user_avatar, user.user_name,
(SELECT COUNT(*) FROM comment
php7正则表达式WHERE comment.post_id = post.post_id) AS commentCount,
(SELECT COUNT(*) FROM post_like
WHERE post_like.post_id = post.post_id) AS likeCount
FROM post, user where post.user_id=user.user_id and post.post_date < "2018-04-05 12:12:35" order by post.post_date desc limit 25
字符常量的定义形式是这⾥post_date可以抓取最后⼀条的post_date⽤来做下次获取的标记值。
但是问题是:如果我想通过view或者likeCount排序分批读取数据,获取的数据中没有可以⽤来做标记,拿来进⾏下次对⽐的标记值。精通专升本
mysql语句如下:
SELECT post.*, user.user_avatar, user.user_name,
(SELECT COUNT(*) FROM comment
WHERE comment.post_id = post.post_id) AS commentCount,
(SELECT COUNT(*) FROM post_like
mysql怎么读英语WHERE post_like.post_id = post.post_id) AS likeCount
缺少jquery插件FROM post, user where post.user_id=user.user_id order by likeCount desc limit 25
⼤家⼀般都是怎么解决的?谢谢
sql语句查询筛选
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论