Created
January 13, 2018 18:03
-
-
Save caub/533e7f1ea5909998bf360c176f94f6da 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 foo ( | |
id bigserial primary key, | |
name text, | |
created date | |
); | |
insert into foo(name,created) values | |
('lol', '2018-01-09'), | |
('lol', '2018-01-08'), | |
('lol', '2018-01-08'), | |
('wow', '2018-01-07'), | |
('wow', '2018-01-09'), | |
('lol', '2018-01-09'); | |
select * from foo order by name, id LIMIT 2; | |
select * from foo where id>2 OR name!='lol' order by name, id LIMIT 2; | |
select * from foo where id>6 OR name!='lol' order by name, id LIMIT 2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so the idea is to add
id
at the end of your order by columns, and then for next page use the starting condtionid>lastId OR col!=lastColValue