Мой запрос LEFT JOIN работает нормально, но я столкнулся с проблемой при упорядочении результатов запроса.
Запрос:
SELECT *
FROM posts
LEFT JOIN comments ON posts.postId = comments.commentId
ORDER BY postDate DESC, commentDate DESC
Вместо комментариев тянутся в конце моего списка.
POSTS
postId (Primary) int(11) AUTO_INCREMENT
postUserId int(11)
postType varchar(10)
postContent text
postCaption text
postState varchar(10)
postVotes int(11)
postDate datetime
И комментарии
commentId (Primary) int(11) AUTO_INCREMENT
commentUserId int(11)
commentFor varchar(20)
commentForId int(11)
commentContent text
commentState varchar(20)
commentVotes int(11)
commentDate datetime
Из комментариев не упорядочены должным образом Необработанные данные, извлеченные из базы данных, сначала извлеченные из комментариев
"1","1","post","1","this is one comment and the only one","published","1","2019-02-05 12:04:00"
И это из сообщений
"1","1","text","this is the first post",,"published","1","2019-02-05 12:02:00"
"2","1","text","this is the second post",,"published","1","2019-02-05 12:16:00"
Желаемый результатдолжно быть как
"2","1","text","this is the second post",,"published","1","2019-02-05 12:16:00"
"1","1","post","1","this is one comment and the only one","published","1","2019-02-05 12:04:00"
"1","1","text","this is the first post",,"published","1","2019-02-05 12:02:00"
Упорядочено по дате / времени