Re: SELECT Question

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: SELECT Question
Дата
Msg-id Pine.LNX.4.33.0311200448190.23198-100000@leary.csoft.net
обсуждение исходный текст
Ответ на Re: SELECT Question  (Alex <alex@meerkatsoft.com>)
Ответы Re: SELECT Question  (Joe Conway <mail@joeconway.com>)
Список pgsql-general

On Thu, 20 Nov 2003, Alex wrote:
> >>Is there an easy way to write a select statement that returns me the
> >>frist free number or any within the range of 200?
> >>For example if 1-30, and 32-50 are occupied then i would like to fill in
> >>the new entry with id 31.

If you had a table with an id column and 200 rows 1-200 you could do

SELECT MIN(idtab.id) FROM idtab LEFT JOIN realtab ON (idtab.id =
realtab.id AND realtab.id IS NULL)

A useful generic function would be one something like range(min,max) that
would return a set of rows so you wouldn't have to actually have a table.

Kris Jurka


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

Предыдущее
От: "Matthew Lunnon"
Дата:
Сообщение: Re: Pg_dumpall problem
Следующее
От: Jean-Michel POURE
Дата:
Сообщение: Re: Japanese and PostgreSQL