From: | Dmitry Tkach <dmitry(at)openratings(dot)com> |
---|---|
To: | Nicholas Allen <nallen(at)freenet(dot)co(dot)uk> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How do you select from a table until a condition is met? |
Date: | 2003-02-12 22:04:17 |
Message-ID: | 3E4AC4E1.3040700@openratings.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>
>
>No. What I'm saying is the user scrolls through a list then selects an item.
>They then decide to sort on something else but they still want the item they
>selected to be selected after the sort has completed. So I need some way to
>work out where the previously selected item will be in the new sort order so
>I can scroll to that position and select it again.
>
>eg If user selects "John Doe" when sorted by First name and then decides to
>sort by Surname I still want John Doe selected and the user should be able to
>see the record.
>
>
What do you mean by 'select the item'? Get all the rows before it?
This still doesn't make much sense to me - you said before, that the
whole purpose of your 'browser' was to avoid sending tons of data to the
client side, but if I understand correctly what you are thinking about
doing, it won't work, because you do not know how many rows are before
the 'selected' item. Am I still missing something?
Anyway, what about this:
select * from people order by last_name, id limit 100; -- get first 100,
ordered by the last_name
select * from people where first_name < 'John' or first_name = 'John'
and last_name <= 'Doe' and id <= "JohnDoe's ID" order by first_name, id;
-- get everything before the last seen John Doe ordered by the first name
select * from people where first_name > 'John' or first_name = 'John'
and last_name >= 'Doe' and id >= "JohDoe's ID" order by first_name, id
limit 100;
-- get 100 rows after the selected one sorted by first name
etc...
Still can't imagine how this can be useful though :-(
Dima
From | Date | Subject | |
---|---|---|---|
Next Message | Nicholas Allen | 2003-02-12 22:21:18 | Possible bug in Postgres? Followup to "How do you select from a table until a condition is met?" |
Previous Message | Johnny Kristensen | 2003-02-12 21:51:41 | SQL Functions vs PL/PgSQL |