SELECT *
FROM chatroom_message cm INNER JOIN users_account ua ON cm.userid_a = ua.reg_userid
INNER JOIN users_account ub ON cm.userid_b = ub.reg_userid
WHERE cm.userid_a = :chat_client OR cm.userid_b = :chat_client
Here 2 connections are changed, one connection for each user in the user table. This is because you have 2 user IDs in the message table that are different from each other (no one will quote for themselves), so you need a connection for userid_a
and another connection for userid_b
.
, , 0 , userid_a
userid_b
. OR
WHERE
.
WHERE
.