List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:June 8 1999 10:32am
Subject:browsing an index, next screen, prev screen etc (C API)
View as plain text  
>>>>> "Michael" == Michael Palm <msp1@stripped> writes:

Michael> This must be something that arises often, but I can't find any mention of it:
Michael> If a user wants to see orders for XYZ around May 1st, I could select orders
Michael> with date >= 1999-05-01 and display a screen. If they hit <next> I
> could get
Michael> the next screen, either with a new select() or from the rows saved by
Michael> mysql_store_result(). What if they hit <prev>? Is there any way to
> select the
Michael> last 15 rows BEFORE 1999-05-01 without creating a separate descending index?
Michael> i.e. will mysql ever search backwards through an index? It would seem that I
Michael> probably need to make them say "OK, it's not there. so show me orders from
Michael> April 1st instead".

Michael> thank you


In the C API, you can mysql_data_seek() to position yourself at any
row if you used 'mysql_store_result'.

You don't have to do a new descending index. In SQL you can do:

SELECT * from table_name where date_column <= 1999-05-01 order by
date_column DESC LIMIT #;

The above will work, but is not that fast for large tables yet.  As
soon as I got 3.23 out I plan to add optimization for the above case to.
call 'read_previous' until the LIMIT clause is satisfied.


browsing an index, next screen, prev screen etc (C API)(Michael Palm)8 Jun
  • browsing an index, next screen, prev screen etc (C API)Michael Widenius8 Jun