http://www.perlmonks.org?node_id=377567


in reply to Re: Building an index for next/last in a photo album.
in thread Building an index for next/last in a photo album.

I had considered that, but the problem is that the img_id's are sequential in the database -- not the album. In other words, if I wanted img_id #43, I could not just say "give me img_id #42, #43 and #44" - because #42 and #44 could possibly belong to another album_id for the same user - or another album_id for a completely different user.

Here is an example of the table:

img_id | album_id | uid | name | ext -------+----------+-----+--------------+------ 38 | 14 | 89 | mypetrat | jpg 39 | 14 | 89 | mypetlemur | jpg 40 | 2 | 12 | vacation_01 | jpg 41 | 14 | 89 | mypetvulture | jpg 42 | 2 | 12 | vacation_02 | jpg 43 | 2 | 12 | vacation_03 | jpg 44 | 14 | 89 | mypetcow | jpg

Replies are listed 'Best First'.
Re^3: Building an index for next/last in a photo album.
by waswas-fng (Curate) on Jul 26, 2004 at 20:41 UTC
    What database? if Mysql you should be able to use a more generic query that limits to the user and album and then use it's INDEX statement to say only the Item N -> N+2.


    -Waswas