As a caution,
I would never, ever use a query that relies on the data to be returned from
the table in a certain order. That is just wrong and goes against the
principals of a rdbms.
Just write your queries in such a way that the result is always returned the
way you want it regardless of the way it is ordered in the table.
2008/9/23 Trullo <[EMAIL PROTECTED]>
> En/na Chris ha escrit:
> > Trullo wrote:
> >> hello_world();
> >> in fact.. how to goTo next/previous row of a table without using
> >> incremental ids AND without reading the whole table?
> >> i will explain:
> >> I wanna do something like a paging toolbar blinded to a list of rows
> >> (for example, a literally view of a db table).
> >> The first difference from a normal paging system, is that i wanna show
> >> only one row per page, and luckily i know the id of that first viewed
> >> row; so, no problem until here. Im able to show the first row xD.
> >> The second difference is that i don't know the position of the first
> >> viewed row inside the whole original table, only the id of the row
> >> (maybe someone is laughing while reading 'only').
> >> I would like to know the position of that row to allow a easy goTo
> >> next/prev method using LIMIT/OFFSET sql clauses.
> > Assuming the row id you have is a primary key, you could do:
> > select * from table where primary_key > $current_rowid order by
> > primary_key asc limit 1;
> > For previous you could do:
> > select * from table where primary_key < $current_rowid order by
> > primary_key desc limit 1;
> Lot of thanks! its true that i dont care about the position of row. Your
> solution will do the work sure :o]
> As a curiosity... then.. the only way to know the position of a row, is
> read the whole table?
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
J.A. van Zanen