Ordering rows in a table

Поиск
Список
Период
Сортировка
От David Härdeman
Тема Ordering rows in a table
Дата
Msg-id 20030217140416.GA461@palpatine.hardeman.nu
обсуждение исходный текст
Ответы Re: Ordering rows in a table  (Andrew McMillan <andrew@catalyst.net.nz>)
Список pgsql-novice
Hi,

the subject of this message may be a bit misleading.

I have the following scenario...I have a menu on a webpage that points to different pages, the table looks something
likethis: 

id SERIAL, title varchar(64), url varchar(256)

Now I'd like to add an admin page where the order of the menu items can be changed. Specifically commands for moving an
entryto the top or bottom of the list would be good. But I have no idea how to do this. 

The ideas I've had som far...

adding an extra sort field (SERIAL), this would allow the order to be swapped between two rows by swapping the value of
theirsort fields....this is not exactly what I want tough. 

I've also considered reading the entire table and calculating new "sort" values for each row but this seems very
ineffectiveand not very "elegant". 

So how would I do this in a "neat" way?

Thanks in advance,
David Härdeman

PS
Please CC any replies to me

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

Предыдущее
От: "Dirk Hamstra"
Дата:
Сообщение: Dynamic IP - pg_hba
Следующее
От: "Denis Grannell"
Дата:
Сообщение: question on "create domain"