Created
April 6, 2018 07:17
-
-
Save sajadshafizadeh/b52b3636033ad0b419d156919de16a3b 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
SELECT n.id, <getting the smallest id of those 15 groups> AS smallest_id | |
FROM notifications | |
WHERE author_id = ? AND id >= smallest_id | |
ORDER BY id DESC; | |
<Smallest id> would be something like that: (it should be just one id, not a set of ids) | |
SELECT MIN(id) | |
FROM notifications | |
WHERE author_id = ? | |
GROUP BY post_id, title, content, date_time | |
ORDER BY id DESC | |
LIMIT 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment