Is it possible to find out by one request from the table of topics theme id
and the last message id
, then from the user table the nickname of the topic author, then from the message table find the author id
last message, and finally again from the user table the nickname of the author of the last message?
Tables topics
- topics, posts
- posts, users
- users.
While it turned out:
SELECT last_post, topics.author_id, topics.username AS author_username, posts.uid AS last_post_uid FROM topics LEFT JOIN users ON topics.author_id=users.id JOIN posts ON topics.last_post=posts.id
The problem is that you need to take two different values from the same table.