gpt4 book ai didi

MySQL显示多个表中的列

转载 作者:行者123 更新时间:2023-11-29 23:20:49 27 4
gpt4 key购买 nike

我有两个表:图书和出版商

图书列为:book_code、title、publisher_code

发布商列为:publisher_code、publisher_name

我正在尝试显示每本书的书名及其 book_code、publisher_code 和publisher_name

到目前为止,这就是我所拥有的:

select book_code, title, a.publisher_code
from book a
inner join publisher p
on a.publisher_code = p.publisher_code;

我不确定如何显示publisher_name

最佳答案

在 mysql 中,我会这样写:

SELECT
b.book_code,
b.title,
b.publisher_code,
p.publisher_name
FROM
book AS b
JOIN publisher AS p USING (publisher_code);

关于MySQL显示多个表中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27320326/

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