gpt4 book ai didi

mysql - SQL语句跨关系访问数据

转载 作者:行者123 更新时间:2023-11-29 09:18:02 25 4
gpt4 key购买 nike

我的 SQL 数据库中有以下表:

authors:
name varchar
id int Primary Key
publications:
id int Primary Key
title mediumtext
year int
authorsJoinTable:
authorId -> Foreign Key to the authors table
publicationID -> Foreign Key to the publications Table
sequenceId int

我想知道是否可以从 authorsJoinTable 获取所有 publicationIds年份降序排列?
提前致谢,
院长

最佳答案

SELECT publicationID
FROM authorsJoinTable a JOIN publications p
ON (p.Id = a.publicationId)
ORDER BY p.Year DESC

关于mysql - SQL语句跨关系访问数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3459306/

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