SELECT GROUP BY latest entry in INBOX msg sent by user
Posted
by
Mohatir S
on Stack Overflow
See other posts from Stack Overflow
or by Mohatir S
Published on 2013-11-02T09:44:22Z
Indexed on
2013/11/02
9:53 UTC
Read the original article
Hit count: 144
i am building a simple PM for my personal website where a user can join and send message to the registered users on my website,
i am stuck in grouping and selecting latest user (by latest msg time) in INBOX page
my table :
id msg_from msg_to msg date in_del out_del
i want to show latest user's id each in a group
here is my SQL query :
SELECT ttalk.id, ttalk.msg_from, users.first_name, users.last_name
FROM ttalk
INNER JOIN users ON ttalk.msg_from = users.id
WHERE ttalk.msg_to = '$_SESSION[user_id]' AND ttalk.in_del='0'
GROUP BY ttalk.msg_from DESC LIMIT 500
Thanks in advance :-)
© Stack Overflow or respective owner