| From: | Kris Jurka <books(at)ejurka(dot)com> |
|---|---|
| To: | Alex <alex(at)meerkatsoft(dot)com> |
| Cc: | Lada 'Ray' Lostak <ray(at)unreal64(dot)net>, <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: SELECT Question |
| Date: | 2003-11-20 09:53:02 |
| Message-ID: | Pine.LNX.4.33.0311200448190.23198-100000@leary.csoft.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-patches |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrei Ivanov | 2003-11-20 10:03:44 | ERROR: nodeRead: did not find '}' [x2] |
| Previous Message | Matthew Lunnon | 2003-11-20 09:38:51 | Re: Pg_dumpall problem |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Manfred Koizar | 2003-11-20 14:33:53 | Re: SELECT Question |
| Previous Message | Holger Klawitter | 2003-11-20 09:24:30 | Re: SELECT Question |