页面结果在[您选择的数据库] [英] Page results in [database of your choice]
问题描述
输入:我有一个巨大的表格PAGE_ME :
创建表PAGE_ME(
ID bigint not null,
NAME varchar(32)not null,
CREATED TIMESTAMP not null
)
/ code>不一定与
创建的相同顺序
。我想显示 5之间的结果。 May 2008 09:03:01
和 3。 2008年8月11:00:01
,一次20个,按时间排序,升序(5.五月第一)。查询应该返回 NAME
和 CREATED
(加上任何你需要的分页结果),所以内部查询是:
从PAGE_ME
选择NAME,CREATED
其中CREATED在'2008-05-05 09:03 :01'and'2008-08-03 11:00:01'
order by CREATED asc
在键盘上,准备好...开始! ;)
从我的 article here and for sql server这里。所有的查询都是为了处理任何你在他们的查询,所以没有技巧只在某些情况下工作。
I'd like to collect the "state of the art" ways to paginate results for any database in this wiki.
Input: I have a huge table PAGE_ME:
create table PAGE_ME (
ID bigint not null,
NAME varchar(32) not null,
CREATED TIMESTAMP not null
)
id
is not necessarily in the same order as created
. I want to display the results between 5. May 2008 09:03:01
and 3. Aug 2008 11:00:01
, 20 at a time, ordered by time, ascending (5. May first). The query should return NAME
and CREATED
(plus whatever you need to paginate the result), so the inner query is:
select NAME, CREATED
from PAGE_ME
where CREATED between '2008-05-05 09:03:01' and '2008-08-03 11:00:01'
order by CREATED asc
On the keyboards, ready ... Go! ;)
Read the paging queries from my article here and for sql server here. All queries are meant to work on whatever query you throw at them, so no tricks which work only in some situations.
这篇关于页面结果在[您选择的数据库]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!