Created
February 21, 2019 21:04
-
-
Save dahngeek/9bcf8cc61a1d4d004c1c44b9de9a5b40 to your computer and use it in GitHub Desktop.
Get the most recent row from a group by query.
This file contains hidden or 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 `contact_id`, `user_id`, `date_backup`, `first_name`, `last_name` | |
FROM tbl_contacts WHERE `date_backup` IN ( | |
SELECT MAX(`date_backup`) | |
FROM tbl_contacts WHERE `user_id`= 1 GROUP BY `contact_id` | |
) | |
ORDER BY `contact_id` DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment