Упорядочение по столбцу / атрибуту левой / внешней объединенной таблицы / ассоциации - PullRequest
0 голосов
/ 23 февраля 2019

Я бы хотел упорядочить записи по created_at ассоциации has_many и перейти к следующему необработанному MySQL-запросу (примечание: 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 (таблица article_associations).

Мой вопрос: почему?что я делаю не так?

...