我需要帮助为两个表创建查询。
第一张表books
已在author
和illustrator
列中有作者(作者姓名)和插图画家(插画家)。
第二个表people
在name
列中也有作者姓名。
第三个表books_people
包含两列book_id
和author_id
以及第三列occupation
这更像是将作者直接放在books
表中,而是创建一个单独的表来创建两个表(一对多)之间的关系(表:books_authors
)。我还需要帮助,使该关系的专栏提交职业。
书籍表:
+----+--------------+----------------+-----------------+ | 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 | +----+--------------+----------------+-----------------+
人员表:
+-------+-----------------+ | id | name | +-------+-----------------+ | 32 | SIU | | 4053 | KIM Eun-jung | | 4055 | HWANG Seung-man | | 28490 | Tamura Ryuuhei | +-------+-----------------+
Books_People表
+----------+-----------+----------------+ | comic_id | person_id | occupation | +----------+-----------+----------------+
预期结果:
+----------+-----------+----------------+ | comic_id | person_id | occupation | +----------+-----------+----------------+ | 1 | 32 | author, artist | | 2 | 4053 | author | | 2 | 4055 | artist | | 4 | 28490 | author, artist | +----------+-----------+----------------+
我在这里尝试做的是在创建关系后“创建”行。