Skip to content Skip to sidebar Skip to footer

People Are Shown Twice On The Chat Page Because Of Query

I am trying to make a facebook style chat page using php. But i have a problem to showing old conversations. You know that facebook left sidebar showing conversations and when you

Solution 1:

The behavior is normal, but you should limit by 1 and sort by time to select the most recent message.

Also in your SQL fiddle I guess you're mixing up from user and to user.

Solution 2:

The actual query is correct because you have a 3-2 and 4-2. To get a unique list for a single user you need to remove the from & to from the select so your distinct applies only for the user you are interested in, not the tuple with all the other stuff in it.

Post a Comment for "People Are Shown Twice On The Chat Page Because Of Query"