Mysql 跨关系访问数据的SQL语句
我的SQL数据库中有以下表:Mysql 跨关系访问数据的SQL语句,mysql,Mysql,我的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
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
按年份排序
降序?提前感谢,
院长。。今天,我了解到表标识符与其别名之间不需要“AS”语法
SELECT publicationID
FROM authorsJoinTable a JOIN publications p
ON (p.Id = a.publicationId)
ORDER BY p.Year DESC
SELECT publicationID FROM authorsJoinTable JOIN publications AS P ON P.id = publicationID ORDER BY P.year DESC