Code:
SELECT wrote.book_id, GROUP_CONCAT(author.author_name)
FROM author, wrote
WHERE author.author_id=wrote.author_id
GROUP BY wrote.book_id
This generates:
Code:
book_id GROUP_CONCAT(author.author_name)
10 John,Mike,Lisa
11 Rachel
This helps to consolidate the values like you were asking instead of the following where each row with a different name is listed one at a time each with its own row.
Code:
SELECT wrote.book_id, author.author_name
FROM author, wrote
WHERE author.author_id=wrote.author_id
which produces:
Code:
book_id author_name
10 John
10 Mike
10 Lisa
11 Rachel
I know this is a late response.
Further reading:
GROUP BY
GROUP_CONCAT()
Bookmarks