Re: How do you select from a table until a condition is met?

Поиск
Список
Период
Сортировка
От Dmitry Tkach
Тема Re: How do you select from a table until a condition is met?
Дата
Msg-id 3E4AC4E1.3040700@openratings.com
обсуждение исходный текст
Ответ на Re: How do you select from a table until a condition is met?  (Nicholas Allen <nallen@freenet.co.uk>)
Список 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






В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: How do you select from a table until a condition is met?
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: null foreign key column