Get one item of duplicate if found

Hi DW. I'm creating a chat system which will alow guests to send DMs to the operator and the operator can reply to it. I'm using MYSQL as my database, fingerprint2js for identifying the user since user has not yet logged in or registered but want to first communicate with the admin.

Scenario here is that the user has sent 2 messages which are bot recorded separately on the database but have the same uid which is the id used to identify the user. My problem is that even the admin when replay he will also use this same uid so the uid is having many duplication as they communicate, issue is that it's not only the two people communicating but others as well which makes it have many duplicates of each uid.
What want to achieve withe the select is to get only a single uid of each even if its its duplicate or not but get one of each so that will be able to iterate through each user and be able to sort their messages for displaying purpose. At the moment I have 2 rows with the same uid but when I use select and while since the number of rows are two it runs twice which end up producing same result twice. On the display side get 4 messages because for each iteration it return both rows when on my select statement I select where uid equal id which is returned by a select all from xchat table where msgfrom equal user. This returned all the uids of the messages since it's only the user that starts a chat now the issue is that a user or admin can send more than one message, how can I get all uids but for duplicates only get 1 id of each so that when I work with it only work once even if there are more than one same uid on the database and also get those that are not duplicates as well.

Thanks.