X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 89F9ED8024 for ; Sun, 4 Sep 2005 15:08:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18490-03 for ; Sun, 4 Sep 2005 18:08:52 +0000 (GMT) Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 7A472D7F2B for ; Sun, 4 Sep 2005 15:08:52 -0300 (ADT) Received: from krogh.officenet.no (unknown [193.212.174.95]) by svr2.postgresql.org (Postfix) with ESMTP id 6314BF0B3F for ; Sun, 4 Sep 2005 19:04:21 +0100 (BST) Received: from krogh.officenet.no (krogh.officenet.no [127.0.0.1]) by krogh.officenet.no (Postfix) with ESMTP id 3EA95155EA3 for ; Sun, 4 Sep 2005 20:08:21 +0200 (CEST) From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-sql@postgresql.org Subject: Re: Help with UNION query Date: Sun, 4 Sep 2005 20:08:20 +0200 User-Agent: KMail/1.8.91 References: <200509041914.33245.andreak@officenet.no> In-Reply-To: <200509041914.33245.andreak@officenet.no> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart12949201.sbyUKUP0Fh"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200509042008.21080.andreak@officenet.no> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/28 X-Sequence-Number: 22575 --nextPart12949201.sbyUKUP0Fh Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Replying to my self... Here's a somewhat simpler version without the IN-queries: SELECT g.id from onp_group g, onp_user_group ug where g.groupname =3D ug.groupname AND ug.username =3D 'andreak' UNION SELECT gc.child_id =46ROM onp_group_children gc, onp_group g, onp_user_group ug WHERE gc.group_id =3D g.id AND g.groupname =3D ug.groupname AND ug.username =3D 'andreak'; But I would very much appreciate if someone manages to rewrite this query s= o=20 that it doesn't specify ug.username=3D'anderak' twice. =2D-=20 Andreas Joseph Krogh Senior Software Developer / Manager gpg public_key: http://dev.officenet.no/~andreak/public_key.asc =2D-----------------------+---------------------------------------------+ OfficeNet AS | The most difficult thing in the world is to | Hoffsveien 17 | know how to do a thing and to watch | PO. Box 425 Sk=F8yen | somebody else doing it wrong, without | 0213 Oslo | comment. | NORWAY | | Phone : +47 22 13 01 00 | | Direct: +47 22 13 10 03 | | Mobile: +47 909 56 963 | | =2D-----------------------+---------------------------------------------+ --nextPart12949201.sbyUKUP0Fh Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQBDGzgVUopImDh2gfQRAlx1AJ9ZhiD+IzCZdc35JafB15cOUlUqXgCffvsO XMWK5eG1sFRF88qgtomDeMo= =r0C/ -----END PGP SIGNATURE----- --nextPart12949201.sbyUKUP0Fh--