I have two tables in my database
Table: userswith columns: id, username, emailetc.
Table: users_messageswith columns: id, to, from, messages,sent_time
The columns toand fromare the keys usersof users. The problem is what I need:
msgstr "select all users in and from username and message".
For example, if a table row looks like this:
From, To, Message
11, 14, Hi, How are you
14, 11, Hello,
and if 11 is john and 14 is a label, then I need the output as follows:
From, To, Message
john, mark, Hi, How are you
mark, john, Hello,
, . , ?
:
SELECT u.username, m.message, m.from, m.to
FROM `users_messages` m, `users` u
where
m.from = u.id and m.to = u.id
LIMIT 0 , 30
, . ?