[thesite] Tip Harvest: Prev / Next Tip

Joshua Olson joshua at alphashop.com
Thu Sep 27 12:31:08 CDT 2001


Hey rudemeister, got a toughy fer ya if yer up fer it.

Let's say you've got a many-to-many relationship between items and
categories with a third table stuck in the middle to create the
associations.  Categories have a primary key id, and items have a primary
key id.  But, let's say I want to select the next and previous item from
within the same category based on a field other than the primary key, such
as the date it was created.

There are two flavors to this:

1.  When I get to the end or beginning of a category, I want to display the
item in the adjacent category (determined by some other arbitrary sort field
having to do with the order of the categories)

2.  When I get to the end or beginning of a category, I want to return "end
of category..." in some form or fashion.

Can this be done in a single query?

-joshua






More information about the thesite mailing list