From: | Holger Klawitter <info(at)klawitter(dot)de> |
---|---|
To: | "Lada 'Ray' Lostak" <ray(at)unreal64(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SELECT Question |
Date: | 2003-11-20 09:24:30 |
Message-ID: | 200311201024.42920.info@klawitter.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-patches |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Thursday 20 November 2003 08:32 schrieben Sie:
> > Is there an easy way to write a select statement that returns me the
> > frist free number or any within the range of 200?
As long as the set of numbers is not too big, the following might work:
CREATE TABLE legal_numbers ( num int );
INSERT INTO into legal_numbers VALUES ( 1 );
... do this with values from 1 to 200;
You can create this table once and for all.
Now the select is rather simple:
SELECT
min(num)
FROM
legal_numbers
WHERE
num not in ( SELECT id FROM other_table )
;
Mit freundlichem Gruß / With kind regards
Holger Klawitter
- --
info(at)klawitter(dot)de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/vIha1Xdt0HKSwgYRAtGbAJ4xR+Naws0vHugt40GH+BJYY/3bAwCdG7t6
2ijqnA8Fm5Z8h4Zhw5H7p3s=
=xsBO
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Matthew Lunnon | 2003-11-20 09:38:51 | Re: Pg_dumpall problem |
Previous Message | Shridhar Daithankar | 2003-11-20 09:23:15 | Re: "Transaction over connections" |
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2003-11-20 09:53:02 | Re: SELECT Question |
Previous Message | Alex | 2003-11-20 07:52:37 | Re: SELECT Question |