+ 3

[SOLVED] How to join two rows in sql

This is my sql code SELECT b.book_id, concat(`first_name`, ' ', a.`last_name`) AS 'author_name', b.title FROM `book_authors` ba JOIN `books` b ON ba.`book_id` = b.`book_id` JOIN `authors` a ON ba.`author_id` = a.`author_id` WHERE b.`book_id` > 0 IN (SELECT c.`book_id` FROM `book_authors` c GROUP BY c.`book_id`) But as you can see in this screenshot below, rows with the same book_id are printed seperately. How can I 'join' them. So that the author field will be comma-seperated or sonething like that https://www.dropbox.com/s/qsicouqkjn22u0t/Capture-1.PNG?dl=0

16th Mar 2020, 9:23 AM
Ore
Ore - avatar
1 Antwort
0
I discovered the group_concat() function in mysql is what i needed
16th Mar 2020, 6:17 PM
Ore
Ore - avatar