Hey.
What have you tried so far?
This looks like a fairly straight-forward SELECT to me. You just need to select rows where the user fields match with the users that are supposed to be a part of the chat.
Also, there is a better way to design the database, but it is a lot more complicated. I wouldn't suggest it until you have a good understanding of how to do SELECTs, as it involves multiple table joins.
In essence, it looks something like this:
- +------+ +------------+ +--------------+
-
| user | | user_convo | | conversation |
-
+------+ +------------+ +--------------+
-
| id |>-| | convo_id |>|->| convo_id |
-
| name | |>| user_id | | | created |
-
+------+ | +------------+ | +--------------+
-
| |
-
| +------------+ |
-
| | message | |
-
| +------------+ |
-
| | msg_id | |
-
\| user_id | |
-
| convo_id |/
-
| text |
-
| sent_at |
-
+------------+
But like I say, the SELECTS for this database would be far more complex than the one you are dealing with now.