I am trying to create a very simple messaging system for a website and I am trying to group the conversations from or to a single SQL statement. I have simplified the statement that I try to use below:
$ messages_query = "SELECT * FROM tbl_messages WHERE from_id = & # 039; $ current_user & # 039; OR to_id = & # 039; $ current_user & # 039; GROUP BY from_id, to_id ORDER BY message_date DESC";
But, of course, the group is a bit off. How would you group it by sender / receiver?