First time the user clicks the user from members list
SELECT * FROM `c` WHERE c.id_m1=10 and `c`.`id_m2`=23
UNION
SELECT * FROM `c` WHERE c.id_m1=23 and `c`.`id_m2`=10
I expect this to return all records from combination
10, 23
23, 10
where 10,23 are ids for the two members from the private conversation
The sql query result in a list of results
list size =0 - (if succesful no one initiated the conversation yet (Create new conversation)
list size =1 - Enter the conversation from with the returned conversation ID(composed with the two members id as composed Key) (open existing conversation)
I guess who opens the conversation does not mather .
I am somehow new to my sql , maybe there are other methods that is what I am thinking right now.
The table is not well build though:
I think autoincrement ID must be remouved
I think that better I would create a Primary composed key from the two ID
id_m1 , Id_m2 as PRIMARY ....no no entry could have a duplicate as the members id are unique as well