【发布时间】:2021-08-25 06:10:41
【问题描述】:
我在 MySQL 员工表中有 4 亿条数据我想每次获取 100 万条记录,因为我在获取前 100 万条记录后使用了限制我想获取接下来的 100 万条记录 记录。
查询==>
select mobile_number ,app_id from employee where department_id='comp' and app_id between '150005050000' and 150005058888' order by app_id limit 0, 100000;
mobile_number app_id
| 919xxxxxxx54 | 150005050035 | <----- first 1 million nth record
| 9199xxxxxxx6 | 150005050035 | <------ I want fetch next 1 million records from this line
| 919xxxxxxx35 | 150005050035 |
| 9189xxxxxxx1 | 150005050036 |
| 9199xxxxxxx6 | 150005050036 |
+---------------+-----------------+
假设这是结果,我得到了我的前 100 万条记录,我想获取下 100 万条记录,但问题是在我的表中 app_id 列有重复值,所以我将如何获取下一条记录 mobile_number 和 app_id 列的组合将使该行是唯一的,所以有什么解决方案,所以我将获取接下来的 100 万条记录,如上表所示;
【问题讨论】:
-
如何编写java jdbc应用程序来获取前100万条记录之后的记录
标签: java mysql query-optimization