Created
October 24, 2012 17:41
-
-
Save tamtam180/3947586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table hoge( | |
id bigint unsigned not null, | |
primary key pk_hoge (id) | |
)engine=InnoDB; | |
pager(slider) | |
< 1 2 3 ... 100 > | |
例えば100万件ある場合、 | |
50を押すと50万番目から表示する。 | |
70を押すと70万番目から表示する。 | |
100等分してスキップするページャー。 | |
idは非連続な値なので、普通のアプリのように最新を表示して、次へ次へ(過去へ過去へ)と表示する場合、 | |
select id from hoge where id < @min order by id desc limit 100 | |
-> min(id)を次のアクセスで@minに使う | |
のように行う事でoffset不要でアクセスできる。 | |
この時に、50を押して50万番目にどーんとスキップしたい場合、 | |
↑のクエリに当てはめようとすると50万番目のidが必要になってしまう。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment