I've built a simple messaging system that uses 5 columns
---------------------------------------------------------------------------------
ID (INT) | toid (INT) | fromid (INT) | message (TEXT) | datetime (datetime stamp)
---------------------------------------------------------------------------------
and I am currently using the following query to show all the messages for the logged in user
SELECT m.fromid as messageid,
photo, forename, surname, m.status, datetime, m.type, message, timestamp
FROM messages m
LEFT JOIN users ON users.userID = m.fromid
WHERE toid ='106'
GROUP BY fromid
ORDER BY datetime DESC
At the moment the query only shows messages once the person replies back to a message (this is because of the WHERE toid = '106'
I am wondering what the correct query would be to show messages for when a conversation is started by the users id '106'