gpt4 book ai didi

MySQL - ID 未正确显示

转载 作者:行者123 更新时间:2023-11-29 22:55:57 25 4
gpt4 key购买 nike

我有一个表 author,shelf,book 这本书的外键为 author_id架子id。作者中的数据为1=Jose2=William Shakespeare。架子上是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,这将覆盖显示。

关于MySQL - ID 未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28724355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com