MySQL-ID未正确显示

MySQL-ID未正确显示,mysql,inner-join,Mysql,Inner Join,我有一个表author,shelf,book这本书有一个author\u id和shelf\u id的外键。 作者的数据是1=何塞,2=威廉·莎士比亚。 在书架上,它是1=历史,2=科学。 我加上它的ID分别是1,1。但当我使用内部连接时。它表现为科学和威廉·莎士比亚。但当我从书中选择*时,它显示为1和1 这是我的问题 select b.book_title, a.author_firstname, ' ' ,a.author_lastname,b.book_description,s.shel

我有一个表author,shelf,book这本书有一个author\u id和shelf\u id的外键。 作者的数据是1=何塞,2=威廉·莎士比亚。 在书架上,它是1=历史,2=科学。 我加上它的ID分别是1,1。但当我使用内部连接时。它表现为科学和威廉·莎士比亚。但当我从书中选择*时,它显示为1和1

这是我的问题

select b.book_title, a.author_firstname, ' ' ,a.author_lastname,b.book_description,s.shelf_description,b.book_quantity 
from book b
inner join author a 
on b.book_id= a.author_id
inner join shelf s 
on b.book_id=s.shelf_id

这是我正确的问题

select 
    b.book_title, a.author_firstname, ' ' ,a.author_lastname) Author ,b.book_description,s.shelf_description,b.book_quantity
     from book b 
     inner join author a 
     on b.author_id= a.author_id
     inner join shelf s
     on b.shelf_id=s.shelf_id

未对齐的原因是book_id的值等于author_id,这将覆盖显示。

请从表格中发布更具代表性的示例,并尽可能将其设置为ho。但是看一下这个,我看到你加入book.book\u id到author.book\u id,你的描述说书有一个通过author\u id的FK,所以应该是book b在b上加入author a.author\u id=a.author\u id。为了更好地理解,请写正确的描述性问题。我遵循了你的建议,它对我来说是正确的@WTFZane可以写下你自己的答案,展示你使用的解决方案。