Skip to content

Instantly share code, notes, and snippets.

@misablaha
Created August 13, 2013 13:50
Show Gist options
  • Save misablaha/6221326 to your computer and use it in GitHub Desktop.
Save misablaha/6221326 to your computer and use it in GitHub Desktop.
# the oldest first - 1. page
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355"
ORDER BY time ASC
LIMIT 5
>>>
{
"data": [
{
"id": "10151928026017355_49217589",
"time": 1372230014
},
{
"id": "10151928026017355_49217612",
"time": 1372230029
},
{
"id": "10151928026017355_49217613",
"time": 1372230029
},
{
"id": "10151928026017355_49217615",
"time": 1372230032
},
{
"id": "10151928026017355_49217616",
"time": 1372230032
}
]
}
# the oldest first - 2. page
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355" AND time > 1372230032
ORDER BY time ASC
LIMIT 5
>>>
{
"data": [
]
}
# the oldest first - 2. page (HACK)
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355" AND time > 1372230032
ORDER BY time ASC
LIMIT 10
>>>
{
"data": [
{
"id": "10151928026017355_49217618",
"time": 1372230034
},
{
"id": "10151928026017355_49217623",
"time": 1372230037
},
{
"id": "10151928026017355_49217625",
"time": 1372230038
},
{
"id": "10151928026017355_49217628",
"time": 1372230039
},
{
"id": "10151928026017355_49217629",
"time": 1372230039
}
]
}
# the newest first
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355"
ORDER BY time DESC
LIMIT 5
>>>
{
"data": [
{
"id": "10151928026017355_58707406",
"time": 1376396984
},
{
"id": "10151928026017355_55210997",
"time": 1375027336
},
{
"id": "10151928026017355_54499578",
"time": 1374747437
},
{
"id": "10151928026017355_53070209",
"time": 1374131648
},
{
"id": "10151928026017355_52894270",
"time": 1374036118
}
]
}
# the newest first - 2. page
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355" AND time < 1374036118
ORDER BY time DESC
LIMIT 5
>>>
{
"data": [
]
}
# the newest first - 2. page (HACK)
SELECT id, time FROM comment
WHERE post_id = "70630972354_10151984553982355" AND time < 1374036118
ORDER BY time DESC
LIMIT 10
>>>
{
"data": [
{
"id": "10151928026017355_52708221",
"time": 1373971849
},
{
"id": "10151928026017355_52267296",
"time": 1373803546
},
{
"id": "10151928026017355_52227225",
"time": 1373779003
},
{
"id": "10151928026017355_52174766",
"time": 1373758633
},
{
"id": "10151928026017355_52115370",
"time": 1373719254
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment