I have this kind of table for simple chat:
messages table structure +----+---------+-----------+---------+------+------+ | id | to_user | from_user | message
You are getting the last message from each user because you have done GROUP BY for both: to_user and from_user.
There is no need to use GROUP BY clause in your query.