Skip to content

Instantly share code, notes, and snippets.

@kashcode
Created June 22, 2017 12:11
Show Gist options
  • Save kashcode/88ad601145ab9283d4976c14e81e2354 to your computer and use it in GitHub Desktop.
Save kashcode/88ad601145ab9283d4976c14e81e2354 to your computer and use it in GitHub Desktop.
SELECT
t.*
FROM
tweets AS t
JOIN (
SELECT
tweet_id
FROM
tweets
WHERE
id = 11618
) AS o ON t.tweet_id = o.tweet_id
AND t.id < if((SELECT MAX(ID) FROM tweets limit 1) = 11618, 11618 + 1, 11618)
OR t.tweet_id < o.tweet_id
ORDER BY
t.tweet_id DESC,
t.id DESC
LIMIT
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment