Re: Help with UNION query - Mailing list pgsql-sql

From Andreas Joseph Krogh
Subject Re: Help with UNION query
Date
Msg-id 200509042008.21080.andreak@officenet.no
Whole thread Raw
In response to Help with UNION query  (Andreas Joseph Krogh <andreak@officenet.no>)
Responses Re: Help with UNION query
List pgsql-sql
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 = ug.groupname AND ug.username = 'andreak'
UNION
SELECT gc.child_id
FROM onp_group_children gc, onp_group g, onp_user_group ug
WHERE gc.group_id = g.id AND g.groupname = ug.groupname
AND ug.username = 'andreak';

But I would very much appreciate if someone manages to rewrite this query so
that it doesn't specify ug.username='anderak' twice.

--
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
gpg public_key: http://dev.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
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øyen      | 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 |                                             |
------------------------+---------------------------------------------+

pgsql-sql by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Help with UNION query
Next
From: Andreas Joseph Krogh
Date:
Subject: Re: Help with UNION query