PHP
SELECT DISTINCT bk.title AS Title, bk.year AS Year, aut.authorname AS Author, cat.category AS Category
FROM book bk
JOIN book_category
I think you might want to look into subquery-ing with the group_concat()
so please give this a try:
group_concat()
will merge the results of the sub-query and provide you with one string of authors separated by a comma-space like this author1, author2, author3
SELECT
DISTINCT bk.title AS Title,
bk.year AS 'Year',
(
SELECT
group_concat(aut.authorname, ', ')
FROM
authors aut
LEFT OUTER JOIN
books_authors bk_aut
ON
aut.id=bk_aut.author_id
WHERE
bk_aut.book_id = bk.book_id
) AS Author
FROM
book bk
ORDER BY
bk.title ASC