Select the Latest Message Between the communication of two user in mysql

后端 未结 6 1884
旧时难觅i
旧时难觅i 2020-12-17 03:33

I have a simple table maintaining messages between users. The table structure looks like

     sender    receiver   message   sendtime
      1          2              


        
6条回答
  •  无人及你
    2020-12-17 03:43

    I take 30 mins to find the solution for this problem because I have thew same problem just take it simple

    SELECT DISTINCT sent_by FROM messages WHERE sent_to = 1 UNION SELECT DISTINCT sent_to FROM messages WHERE sent_by = 1
    

提交回复
热议问题