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

Re: [SQL] joining two simular (but not identical tables)

2005-09-04 Thread Michael Fuhr
On Sun, Sep 04, 2005 at 10:19:12PM +1000, Neil Dugan wrote: > I have two similar but not identical tables. > I would like to create a view that combines the contents of both tables > into a single view, where each record in each table is visible as a > separate record in the view. Sounds like you'

[SQL] joining two simular (but not identical tables)

2005-09-04 Thread Neil Dugan
I have two similar but not identical tables. I would like to create a view that combines the contents of both tables into a single view, where each record in each table is visible as a separate record in the view. table a Column | Type | Modifiers ---+