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.

    1 answer 1

     select t.last_post, t.author_id, p.author_id, u1.username as theme_author, u2.username as last_post_author from topics t join posts p on t.last_post = p.id join users u1 on t.author_id = u1.id join users u2 on p.author_id = u2.id where t.id = __id_нужной_темы__ 

    I think something like that ..

    • Strange .. I did the same with my mind, only LEFT JOIN users AS pusers ON posts.uid = pusers.id Is this my AS removed or left? - sinedsem
    • You can not clean. - Photon