var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Help with complex inner join
I'm working on simple forum and I can't make one query.
I want to show on homepage list of topics where will be the author of the topic and author of last post.
I can make any of them but not together, because there is double inner join to one table (one for topic author and second for last post's author).
Tables (just with necesary parts):
author_id (will be connected directly to Users.id)
last_post_id (will be connected to Posts.id)
author_id (connected to Users.id)
I can start with this and I don't know how to continue:
It will give back topic's names, their authors and ID of last post. And I want to know last post's author's name.
SELECT topics.author_id, topics.last_post_id, users.name,
INNER JOIN users ON topics.author_id = users.id
Can anyone help, please?
Thanks for any response
SELECT topicauthor.name AS topic_author_name
, lastposter.name AS last_poster_authr_name
JOIN users AS topicauthor
ON topicauthor.id = topics.author_id
ON posts.id = topics.last_post_id
JOIN users as lastposter
ON lastposter.id = posts.author_id
You're just genius, man! Tahnks a lot
I haven't heard about "table alias" in Inner join. Thanks for fast help!