There is a table of messages like:
|id|sender_id|recipient_id| date_sent | _______________________________________________ |1 | 100 | 101 |2017-03-02 08:03:45| ----------------------------------------------- |2 | 100 | 101 |2017-03-02 08:10:45| ----------------------------------------------- |3 | 101 | 100 |2017-03-02 09:55:01| And so on. To decrypt:
- Message ID
- Sender ID
- ID of the message recipient
- Date of posting There are more fields of the type of the post itself, but it’s useless.
Need to:
Display dialogs for a specific user with each other user with whom he spoke. (messages vkontakte for example). Those. I need to leave the last message with each user. Moreover, if (as I tried) to hang a group by sender_id, then in the case of an outgoing message, everything is OK, and if the messages are incoming (no answer), they bypass group by. I tried all this through MAX according to this advice. In theory, it seems understandable, but in practice everything goes into the abyss. I have 2 identifiers and how to turn them into one (so that the request understands that 100 and 101, and 101 and 100 is one dialogue. I would be very grateful for any help.