I need assistance creating a query for two tables.
The first table
books
already has an author (the author's name) and illustrator (illustrator) in theauthor
andillustrator
column.The second table
people
also has the name of the author in thename
column.The third table
books_people
has the two columnsbook_id
andauthor_id
and a third column calledoccupation
This is more of a conversion from having the authors directly in the books
table to having a separate table creating a relation between two tables (one-to-many) ( table: books_authors
). I would also need help making the column of that relation submit the occupation.
Books Table:
+----+--------------+----------------+-----------------+ | id | title | author | artist | +----+--------------+----------------+-----------------+ | 1 | Tower of God | SIU | SIU | | 2 | Zippy Ziggy | KIM Eun-jung | HWANG Seung-man | | 4 | Beelzebub | Tamura Ryuuhei | Tamura Ryuuhei | +----+--------------+----------------+-----------------+
People Table:
+-------+-----------------+ | id | name | +-------+-----------------+ | 32 | SIU | | 4053 | KIM Eun-jung | | 4055 | HWANG Seung-man | | 28490 | Tamura Ryuuhei | +-------+-----------------+
Books_People Table
+----------+-----------+----------------+ | comic_id | person_id | occupation | +----------+-----------+----------------+
Expected result:
+----------+-----------+----------------+ | comic_id | person_id | occupation | +----------+-----------+----------------+ | 1 | 32 | author, artist | | 2 | 4053 | author | | 2 | 4055 | artist | | 4 | 28490 | author, artist | +----------+-----------+----------------+
What im trying to do here is "create" the rows after the relations have been made.