Selecting the first row out of many sql joins

Posted by IcedDante on Stack Overflow See other posts from Stack Overflow or by IcedDante
Published on 2010-04-01T21:32:48Z Indexed on 2010/04/01 21:53 UTC
Read the original article Hit count: 194

Filed under:
|
|
|

Alright, so I'm putting together a path to select a revision of a particular novel:

SELECT Catalog.WbsId, Catalog.Revision, NovelRevision.Revision
  FROM Catalog, BookInCatalog
    INNER JOIN NovelMaster
      INNER JOIN HasNovelRevision
        INNER JOIN NovelRevision
        ON HasNovelRevision.right = NovelRevision.obid
      ON HasNovelRevision.Left=NovelMaster.obid
    ON NovelMaster.obid = BookInCatalog.Right
  WHERE  Catalog.obid = BookInCatalog.Left;

This returns all revisions that are in the Novel Master for each Novel Master that is in the catalog.

The problem is, I only want the FIRST revision of each novel master in the catalog. How do I go about doing that? Oh, and btw: my flavor of sql is hobbled, as many others are, in that it does not support the LIMIT Function.

© Stack Overflow or respective owner

Related posts about sql

Related posts about select