MySQL 中的偏移分页使用 ORDER BY Date 返回不一致的结果

发布于 2025-01-17 00:20:18 字数 363 浏览 0 评论 0原文

我最近发现我在 MySQL 中的分页查询在某种程度上被破坏了,经过一些研究,我倾向于相信它来自于我通过 DATETIME 字段对行进行分页这一事实。我的问题是有些行显示在多个页面中,有些行在我的页面中一次不显示。

我的查询通常如下所示:SELECT * FROM Table ORDER BY start ASC LIMIT 12 OFFSET 12start 列是 DATETIME 并且正在使用索引。

据我了解,问题可能来自于多行(数十行)具有完全相同的 start 值。我想在这里问一下,你们中的一些人是否已经遇到过这种情况,并且希望知道该怎么做来纠正这种行为?

预先感谢您的帮助!

I have recently found that my pagination queries in MySQL are somehow broken and, after some research, I tend to believe it comes from the fact that I paginate my rows by a DATETIME field. My issue is that some rows are shown in multiple pages and some are not shown once in my pages.

My queries typically look like that: SELECT * FROM Table ORDER BY start ASC LIMIT 12 OFFSET 12. The start column is a DATETIME and is using an index.

As far as I understand, the issue might come from the fact that multiple rows (dozens) have the exact same start value. I would like to ask here if some of you already faced such a situation and hopefully know what to do to correct this behavior ?

Thanks in advance for your help !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文