Well the third table is just the replies; it sort of works like threads with an access list - you have a “thread” which is the messages table, contains just the title etc. Then you have the posts for the thread which like message_replies. The access table determines who has access to this thread. I hope that makes a little more sense.
Right! That’s just more of a security check to make sure the user viewing the message has access- but I also want to display to the user who has access without going to get another query for this (if possible).
SELECT messages.*
, GROUP_CONCAT(messages_users.userid) AS users
FROM messages
INNER
JOIN messages_users
ON messages_users.mailid = messages.id
GROUP
BY messages.id