我想通过created_at
的{{1}}关联对记录进行排序,并进行以下原始MySQL查询(注意:has_many
和articles_author_associations
):>
article_associations
上面的查询返回的是SELECT
DISTINCT `articles`.*
FROM `articles`
INNER JOIN `articles_author_associations`
ON `articles`.`id` = `articles_author_associations`.`article_id`
LEFT OUTER JOIN `article_associations`
ON `article_associations`.`article_id` = `articles`.`id`
AND `article_associations`.`author_id` = 2
WHERE `articles_author_associations`.`author_id` = 2
ORDER BY `article_associations`.`created_at` DESC
LIMIT 100
关联(created_at
表)上未按LEFT OUTER JOIN
排序的文章。
我的问题:为什么?我在做什么错了?