I am using Ruby on Rails 3.2.2 and MySQL. I have a method ( has_many :through ActiveRecord::Associations) that generates the following SLQ request:
SELECT DISTINCT `articles`.*
FROM `articles`
INNER JOIN `articles_comments_associations` `comment_associations_articles`
ON `comment_associations_articles`.`article_id` = `articles`.`id`
INNER JOIN `articles_comments_associations`
ON `articles`.`id` = `articles_comments_associations`.`article_id`
WHERE `articles_comments_associations`.`comment_id` = 223
AND (articles_comments_associations.user_id IN (2))
I would like to understand what this means INNER JOIN 'articles_comments_associations' 'comment_associations_articles'(note: there are several database table statements for INNER JOIN) and how is it possible that the SQL query works, since I do not have a database table with a name comment_associations_articles. Is this a bug (even if it works as expected) ?
source
share