MySQL Forums
Forum List  »  PHP

Re: Showing recordsets from tables with one (main table) to many (secondary table) relationship
Posted by: Rick James
Date: January 13, 2011 07:44PM

Given fields a,b,c.
You want to ORDER BY a,b,c
And you want to "pick up where you left off", which is at $a, $b, $c.
You want to start with the one _after_ ($a, $b, $c)

WHERE  a >= $a
  AND ( a > $a OR
       (a = $a
           AND   b >= $b
           AND  ( b > $b OR
                 (b = $b
                     AND  c > $c
      ))        ))
ORDER BY a,b,c
Note that 'b' code is essentially the same as 'a'. 'c' code is the last one, so it is simpler.

It won't be very efficient (because of all the ORs). But it does get one test (a >= $a) in before going inefficient.

Options: ReplyQuote


Subject
Written By
Posted
Re: Showing recordsets from tables with one (main table) to many (secondary table) relationship
January 13, 2011 07:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.