Home How can I can all unique user whom I send message and receive message
Reply: 0

How can I can all unique user whom I send message and receive message

user1577
1#
user1577 Published in June 23, 2018, 4:35 am

I have table in which all conversation is stored like this

Suppose I have a table like this (fromUser and toUser is fk from user table)

-----------------------------------------
Id.  |  FromUser  |  toUser  | message  |  
     |            |          |          |
1    |     1      |    2     |  Hi      |
2    |     2      |    1     |  hello   |  
3    |     3      |    1     |  hi      |
4    |     1      |    4     |  hello   |
-----------------------------------------

Desired output for distinct row for user 1 orderBy last updated date

-----------------------------------------
Id.  |  FromUser  |  toUser  | message  |  
     |            |          |          |
2    |     2      |    1     |  hello   |  
3    |     3      |    1     |  hi      |
4    |     1      |    4     |  hello   |
-----------------------------------------

Desired output for distinct row for user 2 orderBy last date

-----------------------------------------
Id.  |  FromUser  |  toUser  | message  |  
     |            |          |          |
2    |     2      |    1     |  hello   |  
-----------------------------------------

Desired output for distinct row for user 3 orderBy last date

-----------------------------------------
Id.  |  FromUser  |  toUser  | message  |  
     |            |          |          |
3    |     3      |    1     |  hi      |
-----------------------------------------

As well for other users

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312401 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO