Originally Posted by
kevin66
when I run a query with two tables, I do not get any data returned.
You are asking for a list of chat messages from user like "john1", where he is chatting with himself (FromUser is same as ToUser). When there are no such chats, nothing is returned!
When you want to get the list of chats from certain user with any other user, you have to link another instance of table Users into query. The querystring will be something like
Code:
SELECT u1.UserName, c.Message, u2.UserName AS ContactPerson
FROM (Chats c LEFT JOIN Users u1 ON u1.UserID = c.FromUser) LEFT JOIN Users u2 ON u2.UserID = c.ToUser
WHERE u1.UserName LIKE "john1"