Skip to content
Advertisement

Need a solution for mysql select data where until

I have a message conversation between two people, user 222 and User 5555, it is displayed like this:

Now I am looking for a solution in PHP / MySQL to display only the messages from User-ID 222 until the message from User-ID 5555.

The result should be:

Actually I have

"SELECT * FROM table_conversations WHERE conversation_id='1' and user_id !='5555' ORDER BY message_id DESC"

but of course this will display me all messages from User-ID 222. What I want are only the last unanswered messages from User-ID 222.

Is there any command or solution in PHP & MySQL to get this result, also working for all other conversations?

Advertisement

Answer

Assuming that the message id specifies the ordering of the messages:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement