Created
April 1, 2012 22:52
-
-
Save jaylevitt/2279270 to your computer and use it in GitHub Desktop.
Posts with position > position of last known ID
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 posts | |
( | |
id int primary key, | |
position int, | |
animal text | |
); | |
INSERT INTO posts | |
(id, position, animal) | |
VALUES | |
(1,1, 'alpaca'), | |
(2,2, 'bird'), | |
(3,3, 'cow'); | |
SELECT * from posts | |
JOIN posts AS last | |
ON posts.id = last.id | |
AND last.id = 2 | |
WHERE posts.position > last.position | |
ORDER BY posts.position; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment