【发布时间】:2017-03-24 08:15:10
【问题描述】:
我在使用分页查询数据库时有一个要求。 分页时,我会给查询提供页面大小和页面索引,如下所示,
select distinct tp.* from kat_task_property tp inner join kat_task_to_workstream ttw on ttw.ttw_frn_task_id = tp.tp_frn_task_id and ttw.ttw_frn_workstream_id= :workStreamId and ttw.ttw_ended_by is null and tp.tp_ended_by is null and tp.tp_is_active=true and ttw.ttw_is_active=true left join kat_user_to_task_order kto on ttw.ttw_id = kto.uto_frn_task_to_workstream_id and kto.uto_frn_user_id = :userId order by tp.tp_completed_at ,kto.uto_order limit :index, :size
样本结果将是,
tp_id tp_completed_at
1 2017-02-27 06:47:52
2 null
3 null
4 2017-03-14 12:59:24
5 null
6 null
7 null
我的要求是当查询中的索引为 0 时,无论查询中的值大小如何,我都应该获取 tp_completed_at 为空的所有数据。我的意思是,当索引为零时不应该应用分页,我应该得到所有 tp_completed_at 为空的条目。并且,当索引的值不是 0 时,应该应用分页。请帮忙
【问题讨论】:
标签: java mysql spring-data