模板:
SELECT
b.BookId AS bookId,
b.BookName AS bookName,
(select group_concat(aa.bookTypeName) from (SELECT bt.bookTypeName AS bookTypeName,b.bookId AS bookId
FROM
wor_booktype AS bt
left join wor_book_booktype AS bb ON bt.BookTypeId = bb.BookTypeId
left join wor_book AS b ON bb.BookId = b.bookId) AS aa where aa.BookId = b.BookId) AS bookTypeNames,
b.BookIsSign AS bookIsSign,
b.UpdateCycle AS updateCycle,
b.BookReviewStatus AS bookReviewStatus,
b.UserId AS userId,
b.Sort AS sort
FROM
wor_book AS b
left join
wor_book_booktype AS bb ON bb.BookId = b.BookId
left join
wor_booktype AS bt ON bt.BookTypeId = bb.BookTypeId
where b.IsHide NOT IN ('1')
GROUP BY
b.BookId
ORDER BY FIELD(b.BookReviewStatus,'已审核','审核中','未审核','已下架')
结果: