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