It looks like you have the duplicate rows because one of the users is the "writer" and the other is the "reader". I'm guessing that you actually want one row for each row in chat_comms
linked to both the "writer" and "reader". In this case you need to join to utilizadores
twice instead of using the or
:
select message, writer.first_name, writer.last_name, dataPost, picture
from chat_comms
left join utilizadores writer on chat_comms.id_writer = writer.id_user
left join utilizadores reader on chat_comms.id_reader = reader.id_user
where id_writer = 1
or (id_reader = 1 and id_writer = 13)
order by dataPost ASC
This is just a guess because you haven't adequately described the result you're trying to achieve.