Re: [SQL] Help with UNION query

2005-09-06 Thread Bruno Wolff III
On Sun, Sep 04, 2005 at 20:54:00 +0200, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > So, the question stands: any idea on how to rewrite the lower wuery to only > specify "ug.username='andreak'" once? Why do you want to do that? This isn't going to help with performance and may actually

Re: [SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
On Sunday 04 September 2005 20:08, Andreas Joseph Krogh wrote: > Replying to my self... Again... I managed to "reduse" my query to the following: SELECT gr.groupname FROM onp_group gr, onp_user u WHERE gr.id IN ( SELECT g.id FROM onp_group g, onp_user_group ug WHERE g.groupname =

Re: [SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
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.i

[SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
Hi all, I have the followin query: SELECT g.id from onp_group g where g.groupname IN (SELECT ug.groupname from onp_user_group ug WHERE ug.username = 'andreak') UNION (SELECT child_id FROM onp_group_children WHERE group_id IN (SELECT g.id from onp_group g