vendredi 15 juillet 2016
Get Last row in each group and order whole array by ID(pk) DESC and join with other Table
I want the last row in each and every group(Group By user_id).
Structure of Table is like follows:
Table: user_messages
id(PK) | user_id(FK) | read_admin_status | created_at
1 5 0 date
2 5 0 date
3 5 0 date
4 5 1 date
5 6 1 date
6 6 1 date
7 7 0 date
8 7 0 date
Table: users
id | username
Now I want username from users tables and I want other details from user_messages.
Now I want data of user_id 5 and want it's last row only.
likewise for other groups I want last row of each group and from users table I want username by joining the tables.
Please help me out with this if you can. Thank you.
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire