View Single Post
Old 04-27-2012, 02:30 AM   PM User | #8
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I think this is *close* to what you want:
Code:
SELECT webName, value AS titleSort, value AS title, pageID, X.catID, pageName, sortBy 
FROM pages, pagesCats, pagesIndex,
    ( SELECT catID, MIN(sortBy) AS minsort 
      FROM pagesIndex,pages 
      WHERE pages.ID=pagesIndex.pageID GROUP BY catID ) AS X
WHERE pagesIndex.catID = X.catID
  AND pagesindex.pageID = pages.ID
  AND pages.sortBy = X.minsort
  AND pagesCats.ID = X.catID
  AND subsetof = '2'
ORDER BY X.minsort, pageID
But it does get duplicate catID/sortBy values. I'm not sure if you want that or not.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
katyD (04-27-2012)