次の mysql は、DB 内の最初の 10 件の投稿と、それらの 10 件の投稿に関連付けられたコメント、および投稿に関連付けられたユーザーを返します。すべてが投稿のタイトルでソートされます。
SELECT * FROM
(SELECT * FROM posts LIMIT 0,10 ORDER BY posts.title) as post
LEFT JOIN comments AS comment ON comment.postId = post.id,
authors AS author
WHERE post.authorId = author.id
author.name で並べ替えるにはどうすればよいですか? posts.title を author.name に変更すると、エラーが発生します。
Table 'comment' from one of the SELECTs cannot be used in global ORDER clause