我的问题是我使用查询,当我先调用它时必须返回N值,然后 下一个N值等。我也有一些类型的排序,如按日期排序,按字名等排序,asc和desc变种。我使用按日期排序的地方我可以使用像id> N(在我的代码中> 3)的东西,即第一个id是4,最后一个id是9然后在下一个查询中首先是10和最后15等等但是该做什么如果我需要按字名排序,我怎样才能确定从哪个词开始?
select distinct s.a,w._word
from (
select a from edges
where a in
(
select distinct w._id
from edges as e
inner join words as w
on w._id=e.a
where w.lang_id=2
) and b in
(
select distinct w._id
from edges as e
inner join words as w
on w._id=e.b
where w.lang_id=1
)
union
select b from edges
where b in
(
select distinct w._id
from edges as e
inner join words as w
on w._id=e.b
where w.lang_id=2
) and a in
(
select distinct w._id
from edges as e
inner join words as w
on w._id=e.a
where w.lang_id=1
)
) as s
inner join words as w
on s.a=w._id
inner join groups_set as gs
on w._id=gs.word_id
where gs.group_id in (1,2,3) or w._word like '%d%' and a>3
order by w._word desc limit 5
答案 0 :(得分:1)
我的问题是错的吗? LIMIT
可以与偏移量一起使用。
要么
... LIMIT 5 OFFSET 5
或
... LIMIT 5, 5
您不在查询中处理偏移量,只需在应用程序中增加它。
有了这个,你也可以ORDER BY
随心所欲。