views:

23

answers:

2

Hi, I have the following tables in my SQL Database:

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

I am wondering if it is possible to get all the publicationIds from the authorsJoinTable ordered by year descending?
Thanks in Advance,
Dean

+2  A: 
SELECT publicationID
FROM authorsJoinTable a JOIN publications p
     ON (p.Id = a.publicationId)
ORDER BY p.Year DESC
Michael Pakhantsov
+1 .. today I learned "AS" syntax is not required between a table identifier and its alias. :)
sleepynate
True, but I think `AS` improves readability (personally)...
ircmaxell
A: 
 SELECT publicationID FROM authorsJoinTable JOIN publications AS P ON P.id = publicationID ORDER BY P.year DESC
sleepynate